Skip to:
Content
Pages
Categories
Search
Top
Bottom

How Do I link to Profile Page


  • Steve
    Participant

    @aksteve

    OK. I keep asking this question, but get no answer or people try to sell me plugins.

    How can I create a link so my members can update their profile?

    I see posts on this forum about the profile page but no explanation on how to link to it.

    There is a way to do right? Even on this very forum I see a login link at top right. I can then edit my profile, see posts I wrote, etc. So this exist.

    How can I create these links? Is it not part of the core? I hope someone can help. Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Steve,

    As Robin answered, you could look into his coding for the bbP Style Pack to see how it works.

    There is also https://codex.bbpress.org/layout-and-functionality-examples-you-can-use/#8-add-edit-profile-to-a-wordpress-menu that might give you a hint.

    Pascal.


    Steve
    Participant

    @aksteve

    Ok. Thank you.

    I guess that answers my questions.

    The question being, is there a way to add a “my profile” link to a menu.

    The answer is, if I am hearing correctly. Yes, sorta, if you edit some function files.

    And the answer is also, No – there is no way to do this with bbPress. bbPress does not offer a way for people to edit their profiles unless the user is savy enough to know they should click their profile name in a forum post to see/edit their profile.

    I just assumed there would be an easy way to do this. It seems a core function. But I guess I am wrong.

    Makes me wonder how others make “profile” pages for their users?

    Thanks for the answer.


    tylertervooren
    Participant

    @tylertervooren

    @aksteve – I had the same frustration. Try this simple plugin I just created. It’ll print the profile url via a shortcode so you can insert it anywhere you like.


    boborg
    Participant

    @boborg

    @tylertervooren where can I get the simple plugin you created?


    tylertervooren
    Participant

    @tylertervooren

    Huh… looks like my link got stripped. Here it is: https://wordpress.org/plugins/bbp-profile-link-shortcode/


    jonathanmoorebcsorg
    Participant

    @jonathanmoorebcsorg

    after some difficulty I came up with a solution, which allows a standard menu item linking to eg:
    forums/users/current

    If a request is made to http://mysite/forums/users/current, the user name “current” is detected and replaced with the current user id, or, if the user is not logged in, redirect to login screen:

    
    /*
     * attempt to handle generic request for current user
     *
     * if the url is passed as forums/users/current/
     * this function detects that the permalink has been set to bbp_user=current
     * and
     *  - if the user is logged on, the query is changed to the current user
     *  - if the user is not logged on, the user is redirected to login screen
     *
     */
    function ink_bbp_request_current_user( $query_vars ) {
    	if ( isset( $query_vars[ 'bbp_user' ] ) ) {
    		switch ( $query_vars[ 'bbp_user' ] ) {
    			case 'current':
    				if ( get_current_user_id() ) {
    					$query_vars[ 'bbp_user' ] = bbp_get_current_user_name();
    				} else {
    					auth_redirect();
    				}
    		}
    	}
    	return $query_vars;
    }
    
    add_filter( 'bbp_request', 'ink_bbp_request_current_user', 10, 1 );
    

    ryanrain
    Participant

    @ryanrain

    @jonathanmoorebcs for me, your code works great for admin users, but fails for contributor role users


    ryanrain
    Participant

    @ryanrain

    small tweak to not break for users with names that include spaces. the issue was not a permissions one as i posted above.

    
    /*
     * attempt to handle generic request for current user
     * https://bbpress.org/forums/topic/how-do-i-link-to-profile-page/
     *
     * if the url is passed as forums/users/current/
     * this function detects that the permalink has been set to bbp_user=current
     * and
     *  - if the user is logged on, the query is changed to the current user
     *  - if the user is not logged on, the user is redirected to login screen
     *
     */
    function ink_bbp_request_current_user( $query_vars ) {
    	if ( isset( $query_vars[ 'bbp_user' ] ) ) {
    		switch ( $query_vars[ 'bbp_user' ] ) {
    			case 'current':
    				if ( get_current_user_id() ) {
    					$query_vars[ 'bbp_user' ] = bbp_get_user_nicename(get_current_user_id());
    				} else {
    					auth_redirect();
    				}
    		}
    	}
    	return $query_vars;
    }
    
    add_filter( 'bbp_request', 'ink_bbp_request_current_user', 10, 1 );
    
Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar