MyBB Community Forums

Full Version: Link to diffrent page when username clicked
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey this is possibly quite a complicated modification what im trying to do is change the link when you click on a usersname.

Like when i post this my name will be displayed what i want to do insttead of linking to the in forums profile link to a page on my website, so all i really need to do is change a link but as this appears on so many diffrent pages im not sure where to look for the code to edit?

anyhelp is greatly appreciated
thanks
most "username" links or made by the "build_profile_link($username, $uid)" function located in inc/functions.php , you could change the href="" . Or did i misunderstand your question ? =/ =P
No i dont htink youv misunderstood at all
function build_profile_link($username="", $uid=0, $target="")
{
		return "<a href=\"".get_profile_link($uid)."\"{$target}>{$username}</a>";
	}
}
Im attempting to alter this line but finding every attempt creating a t_string error
im trying to link to say mysite\profiles.php it seems i cant simply alter it too
<a href=\""www.mysite\profiles.php "</a>";
as this keeps creating the error

im thinkin i can then use $username, store it as a cookie
and use the cookie to read the data for the user stored in $username
from my mysql database on my page mysite/profiles.php


LeX- Wrote:most "username" links or made by the "build_profile_link($username, $uid)" function located in inc/functions.php , you could change the href="" . Or did i misunderstand your question ? =/ =P
Do you know php? You have to backslash " and '
Tikitiki Wrote:Do you know php? You have to backslash " and '

Hey im new to php im learning it as i go along for this project im quite good with some aspects like intergrating with mysql but have huge gaps in knowledge as im by no means experianced

im still having issues with this im afrad i tried entering the links like
"<a href=\"wwww.thewu.site23.co.uk\"</a>"
and
"<a href=\" 'wwww.thewu.site23.co.uk' \"</a>"
because i wasnt 100% sure
this is the actual code
function build_profile_link($username="", $uid=0, $target="")
{
	global $lang;

	if(!$username && $uid == 0)
	{
		// Return Guest phrase for no UID, no guest nickname
		return "<a href=\"wwww.thewu.site23.co.uk\"</a>";
	}
	elseif($uid == 0)
	{
		// Return the guest's nickname if user is a guest but has a nickname
		return "<a href=\"wwww.thewu.site23.co.uk\"</a>";
	}
	else
	{
		// Build the profile link for the registered user
		if(!empty($target))
		{
			$target = " target=\"{$target}\"";
		}
		return "<a href=\"wwww.thewu.site23.co.uk\"</a>";
	}
}
but it still links back to the in-forum profile have i misunderstood and edited the wrong section? iv left the $target bit of code in as i dont want to course errors along the way, these questions probably seem a bit moronic but im pretty confused with this
thanks
The ProfileLink in the postbit, is made in inc/functions_post.php

		$post['profilelink'] = "<a href=\"".str_replace("{uid}", $post['uid'], PROFILE_URL)."\">".format_name($post['username'], $post['usergroup'], $post['displaygroup'])."</a>";
LeX- Wrote:The ProfileLink in the postbit, is made in inc/functions_post.php

		$post['profilelink'] = "<a href=\"".str_replace("{uid}", $post['uid'], PROFILE_URL)."\">".format_name($post['username'], $post['usergroup'], $post['displaygroup'])."</a>";

Big GrinThank you very much works a treat Big Grin
Hey one last question on this subject as then im done with the modifications i need to make!

With the modifications listed above im only left with the memberlist linking to the inbuilt profile system( i want to link to an external page when a username is clicked)

Iv been through function.php, functions_user.php, functions_post.php, member.php and member_list.php but cannot find what needs to be alterd to change where the usernames on the member list links?

thanks again for any help
wez87 Wrote:Hey one last question on this subject as then im done with the modifications i need to make!

With the modifications listed above im only left with the memberlist linking to the inbuilt profile system( i want to link to an external page when a username is clicked)

Iv been through function.php, functions_user.php, functions_post.php, member.php and member_list.php but cannot find what needs to be alterd to change where the usernames on the member list links?

thanks again for any help

That's made in the "memberlist_row" template =P

<td class="trow1"><a href="member.php?action=profile&amp;uid={$users['uid']}">{$users['username']}</a></td>
Big Grin Thank you again youv been a great help with this

Ok for any who stumble on this post lookin for the same solutions as me heres exactly what i changed and how it was changed

inc/functions.php Line 3104
return "<a href=\"".get_profile_link($uid)."\"{$target}>{$username}</a>";
To
return "<a href=\"http://www.mylink.co.uk\"{$target}>{$username}</a>";

making sure to leave the target and username variables as these display who the post is made by on the thread list

inc/functions_post.php line177
$post['profilelink'] = "<a href=\"".str_replace("{uid}", $post['uid'], PROFILE_URL)."\">".format_name($post['username'], 
$post['usergroup'], $post['displaygroup'])."</a>";

change to
$post['profilelink'] = "<a href=\"http://www.thewu.site23.co.uk\"".str_replace("{uid}", $post['uid'], PROFILE_URL)."\">"
.format_name($post['username'], $post['usergroup'], $post['displaygroup'])."</a>";

Then to change the member list go to the admin area templates>modify/delete>
Expand 'membet list templates edit memberlist_row
edit 2nd and 3rd row to
<td class="trow1"><a href="http://www.tmysite.co.uk">{$users['username']}</a></td>