Forums

Join
bbPress Support ForumsTroubleshootingGet Profile Links

Info

Get Profile Links

  1. bb_get_profile_link(bb_get_current_user_info( 'id' ))

    Is there any way to get the URL to the logged in user's profile without all that "view your profile" junk it tacks onto the above call?

    I am trying to customize my logged-in.php into something like:

    <ul>
    <li>Profile</li>
    <li>Edit</li>
    <li>PM</li>
    <li>Favorites</li>
    <li>Logout</li>
    </ul>

    Except I can never get it to pump out clean URLs =/

  2. function bb_get_admin_link( $args = '' ) {
    	if ( !bb_current_user_can( 'moderate' ) )
    		return;
    	if ( $args && is_string($args) && false === strpos($args, '=') )
    		$args = array( 'text' => $args );
    
    	$defaults = array('text' => __('Admin'), 'before' => '', 'after' => '');
    	$args = wp_parse_args( $args, $defaults );
    	extract($args, EXTR_SKIP);
    
    	$uri = esc_attr( bb_get_uri('bb-admin/', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) );
    
    	return apply_filters( 'bb_get_admin_link', $before . '<a href="' . $uri . '">' . $text . '</a>' . $after, $args );
    }

    So if you don't mind bypassing the moderation ability check, just use
    esc_attr( bb_get_uri('bb-admin/', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) );
    or
    bb_get_uri('bb-admin/', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
    depending if you'll be escaping the URL later.

    To keep the check, use if ( bb_current_user_can( 'moderate' ) )

  3. I was going to hide it behind tags:
    <?php if ( bb_is_user_logged_in() ) : ?>

    What I wanted to do was to replace the standard:
    <?php if ( is_bb_profile() ) profile_menu(); ?>

    With other things including links for the "Your Profile", "Edit (your) Profile", PM Inbox, Memberslist, "Logout" etc.

    Basically I am trying tp bypass the profile_menu() non-global status along the lines of this thread that I wasn't able to work:
    http://bbpress.org/forums/topic/profile_menu-doesnt-work-on-all-pages

    I was trying to force the URL and trying to force such a global profile menu using:
    <?php echo bb_option('uri'); ?>/profile/<?php echo bb_get_current_user_info( ' name ' ); ?>

    But that is pretty ghetto and as you can see it outputs the display name not the username so thus can't be used for getting a link to the user's profile...

  4. Use this:
    bb_get_profile_link('id='.strval(bb_get_current_user_info( 'id' )).'&text=YOUR_TEXT_HERE&before=BEFORE_THE_LINK&after=AFTER_THE_LINK');

    You can view the function here:
    http://trac.bbpress.org/browser/trunk/bb-includes/functions.bb-template.php#L2768

  5. Or you can just call get_user_profile_link(); function to get the simple link.
    If the user is logged in, it will automatically get the user id.

    Function can be found here -
    http://trac.bbpress.org/browser/trunk/bb-includes/functions.bb-template.php#L2195

  6. You must log in to post.