bbPress

Simple, Fast, Elegant

bbPress support forums » Installation

using bb_get_profile_link

(8 posts)
  • Started 2 months ago by parthatel
  • Latest reply from byles
  • This topic is not resolved

Tags:

  1. parthatel
    Member

    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 2 months ago #
  2. 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 2 months ago #
  3. parthatel
    Member

    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 2 months ago #
  4. 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 2 months ago #
  5. parthatel
    Member

    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:

    http://mydomain.com/%3Ca%20href='http://mydomain.com/links/profile.php?id=2'>View%20your%20profile</a>

    Posted 2 months ago #
  6. byles
    Member

    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 2 weeks ago #
  7. no, bb_get_profile_link does 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 2 weeks ago #
  8. byles
    Member

    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!

    Posted 2 weeks ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.