Info
- 8 posts
- 4 voices
- Started 3 years ago by parthatel
- Latest reply from byles
- This topic is not resolved
using bb_get_profile_link
-
- Posted 3 years ago #
How do I make a link that directs the user to their profile?
The default code in bbPress is
<?php printf(__('Welcome, %1$s!'), bb_get_profile_link(bb_get_current_user_info( 'name' )));?.Yet if I use this, the name of the user will be the linked text. Also, I'm not able to use this code alone. If I try:
<?php bb_get_profile_link(bb_get_current_user_info( 'name' )); ?>...it doesn't work. I also tried:
<a href="<?php bb_get_profile_link(); ?>">My Profile</a>How can I change the text to My Profile and also let it stand alone? (standalone meaning on its own paragraph and with no Welcome, %1$s!)
-
- Posted 3 years ago #
bbPress functions with the word "get" in them do not self-echo, they simply return the string. So you have to add echo. You almost have it, for example, this should work:
<a href="<?php echo bb_get_profile_link(); ?>">My Profile</a>And just to confuse you, there are a couple of legacy functions with the word "get" in them that do echo. But they shouldn't and are rare so don't worry too much, lol.
-
- Posted 3 years ago #
I tried that and this is what I get as the url of the link:
http://mydomain.com/%3Ca%20href='http://mydomain.com/links/profile.php?id=1'>View%20your%20profile -
- Posted 3 years ago #
parthatel: can you post your actual HTML from the rendered page in backticks so it doesn't get rendered as HTML? Like you did in the first post. Thanks.
-
- Posted 3 years ago #
This is the warning that appears on the top of the page.
<b>Warning</b>: parse_url(/%3Ca%20href=%27http://mydomain.com/links/profile.php?id=2%27%3EView%20your%20profile%3C/a%3E) [<a href='function.parse-url'>function.parse-url</a>]: Unable to parse URL in <b>/home/domain/public_html/links/bb-includes/functions.php</b> on line <b>1794</b>This is what the My Profile link links to:
-
- Posted 3 years ago #
bb_get_profile_link does self echo, so you could try:
<a href="<?php echo user_profile_link(bb_get_current_user_info('id')); ?>/">...or if you don't want to use it amongst another href, just use:
<?php echo bb_profile_link('link text here'); ?> -
- Posted 3 years ago #
no,
bb_get_profile_linkdoes not self echo but it does return a full formed url apparently, so I was half wrong to use it inside of a href.The direct link is via
get_user_profile_link( $id )byles, your code is wrong in that it doesn't need an echo
<?php bb_profile_link('link text here'); ?> -
- Posted 3 years ago #
I apologise - was writing it from memory and in a rush! :) (excuses excuses ;))
I personally needed to use href to append more to the end.
I've just noticed that the post prior to mine is months old anyway, I guess he figured it out in the end!
-
You must log in to post.