Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Changing Username URL in threads
My forum is highly integrated into my website and I want the Username links to go to their website profile independant of Vanilla.
I've managed to do this for people replying to a thread but not for the thread starter. Can anyone help?
For the username of those replying, this worked successfully in forum/applications/vanilla/views/discussion/helper_functions.php:
Replaced:
echo UserPhoto($Author); echo UserAnchor($Author);
With
echo UserPhoto($Author); $AName =$Sender->EventArguments['Author']->Name; echo '<a href="http://www.website.com/'. $AName .'">'. $AName .'</a>';
However, I tried doing the exact same change for the thread starter (located in discussion.php of same directory) but it just made the username not show.
Replaced:
if ($UserPhoto) { echo UserPhoto($Author); echo UserAnchor($Author, 'Username'); } else { echo UserAnchor($Author, 'Username'); echo UserPhoto($Author); echo FormatMeAction($Discussion);
With:
echo UserPhoto($Author); $AName =$Sender->EventArguments['Author']->Name; echo '<a href="http://www.website.com/'. $AName .'">'. $AName .'</a>';
I'm no coder... please can someone help?
0
Comments
I am a little confused as to what you are trying to achieve. I can tell you that you shouldn't be editing core files.
Assuming you want every profile link to go somewhere else, define a function in your favorite bootstrap file (e.g.
/conf/bootstrap.before.php
) that is calledUserUrl
. Here is the default definition:Modify that to return whatever URL you want and this will automatically be used everywhere.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Thanks I've just created a new file /conf/bootstrap.before.php and inside put your code with some dummy url to test:
But the url didn't change
Ok got it sorted. Using what you said, I found someone else mention something similar and this works for me:
Thank you!
That function doesn't appear to replace the URL when someone quotes a username like so @Mark
Can anyone help there?
You would have to install a mentions formatter that would handle the mentions formatting.
This is because the mentions formatting doesn't have access to the user object, just the user reference. This is for scalability reasons, I assume.
Add the following to your
/conf/bootstrap.early.php
file:Then you need to create a class called CustomMentions in the
/conf/custommentions.php
file. The class must define aFormatMentions
method that accepts a single mixed type argument. E.g.:Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Thank you - that worked
The custommentions code is causing an issue where upon creating a new dicussion, it doesn't redirect the user back to the forum but instead just hangs on the same page with following error:
Fatal error: Call to undefined method CustomMentions::GetMentions() in /home/mysite/site/public_html/forum/library/core/functions.general.php on line 1405
Anyone?
Do you still have the
/conf/bootstrap.early.php
file?My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
Yes, currently has:
Are you using 2.2a? Looks like you need to implement
getMentions
.Copy over this:
https://github.com/vanilla/vanilla/blob/master/library/core/class.format.php#L1472-L1503
to a new function called
getMentions($Mixed)
in the custommentions.phpMy themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
I'm using 2.1.9
I tried doing the following in custommentions.php anyway but no luck:
If you are on 2.1 you need to use this part from the 2.1 source
https://github.com/vanilla/vanilla/blob/release/2.1/library/core/class.format.php#L1167-L1199
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
Yep that code worked... thank you @Bleistivt
This worked wonders on 2.1 but I don't think I can get it to work on 2.2. Are there any updates? Thanks
thanks all. Here's what I was looking for