Skip to:
Content
Pages
Categories
Search
Top
Bottom

Opening Subscriber’s profile editor from toolbar


  • madflute
    Participant

    @madflute

    Hi, After a Subscriber role logged in using bbP Login Widget, the user name links to /forums/users/{username} where the Subscriber can edit their profile as well as uploading their avatar.

    I need this link from the toolbar under the User Name as well as the Dashboard link (and most importantly I need to disable the canned WP profile page because it is very misleading, especially it suggests you can edit your profile but you can’t).

    Is this possible? Hope this is the right place to ask this question. Thank you in advance.

Viewing 16 replies - 1 through 16 (of 16 total)

  • Robin W
    Moderator

    @robin-w

    bbp style pack

    lets you add an ‘edit profile’ to the menu see

    dashboard>settings>bbp style pack>login

    and also has a shortcode that you can put into a text widget in the sidebar

    [bsp-profile’ label=’Edit Profile’ edit=’y’]

    see

    dashboard>settings>bbp style pack>shortcodes


    madflute
    Participant

    @madflute

    For some reason, this plugin killed my site :_(

    ==========

    An error of type E_ERROR was caused in line 68 of the file /home/xxxx/public_html/wp-content/plugins/bbp-style-pack/bbp-style-pack.php. Error message: Uncaught Error: Call to undefined function bbp_get_version() in /home/xxxx/public_html/wp-content/plugins/bbp-style-pack/bbp-style-pack.php:68


    Robin W
    Moderator

    @robin-w

    do you have bbpress activated ?


    madflute
    Participant

    @madflute

    Yes very much. In fact, the login widget is bb Press 🙁


    madflute
    Participant

    @madflute

    Hmmm, something might be wrong with my bbPress. I need to investigate.


    Robin W
    Moderator

    @robin-w

    hmmm, that function only fires when all plugins are loaded, suggest you try activating it again


    madflute
    Participant

    @madflute

    I installed it on another WP site and it didn’t crash so it seems my sandbox is broken. Sorry about that.

    I was not able to find the way to what I am looking for, that is, to have Subscriber’s toolbar links of Edit Profile and Dashboard to the same page, /forums/users/{username} that the bbPress login widget gives. Can this plugin do it?


    Robin W
    Moderator

    @robin-w

    no, I recommend that generally you should disable toolbar for all but admins, plenty of plugins do that.


    madflute
    Participant

    @madflute

    Understood. Altho visitors love their avatar shows up at the top.

    Now I need to hide Edit Profile menu item to all other than Subscriber but can’t find the way. Is there a way?


    Robin W
    Moderator

    @robin-w

    This code will change the WordPress profile to bbpress profile

    add_action('wp_before_admin_bar_render', 'rew_admin_bar_remove_wp_profile', 0);
    
    function rew_admin_bar_remove_wp_profile() {
            global $wp_admin_bar;
    
            /* **edit-profile is the ID** */
            $wp_admin_bar->remove_menu('edit-profile');
     }
    
    add_action('admin_bar_menu', 'rew_add_bbp_profile', 999);
    
    function rew_add_bbp_profile($wp_admin_bar) {
    	
    			$current_user = wp_get_current_user();
    			$user=$current_user->user_nicename  ;
    			$user_slug =  get_option( '_bbp_user_slug' ) ;
    			if (get_option( '_bbp_include_root' ) == true  ) {	
    				$forum_slug = get_option( '_bbp_root_slug' ) ;
    				$slug = $forum_slug.'/'.$user_slug.'/' ;
    			}
    			else {
    				$slug=$user_slug . '/' ;
    			}
    			
    			$profilelink = '/' .$slug. $user . '/edit' ;
    			
    			$wp_admin_bar->add_node( array(
    				'parent' => 'user-actions',
    				'id'		=> 'bbp-edit-profile',
    				'title' => 'Edit Profile',
    				'href' => $profilelink,
    			) );
    
    }

    Put this in your child theme’s function file – or use

    Code Snippets


    madflute
    Participant

    @madflute

    Thank you so so so much! This code is working great. Just one last thing. How can I make this code run only when the user role is Subscriber? -Hiro


    Robin W
    Moderator

    @robin-w

    do you really mean WordPress role subscriber or bbpress role participant ?


    madflute
    Participant

    @madflute

    I always get confused about the relationship since WP and bbP are SSO 🙁

    The new public registration is always WP Subscriber, who is subscribed to bbP Announcement forum by bbP Toolkit. This is the only user role that needs to go to bbP edit-profile page. The other role in use is the Contributor which should jump to wp-admin/profile.php instead of bbP edit-profile. I hope this is somewhat clearer.


    Robin W
    Moderator

    @robin-w

    untested but try

    if ( current_user_can( 'subscriber' ) ) {
    add_action('wp_before_admin_bar_render', 'rew_admin_bar_remove_wp_profile', 0);
    add_action('admin_bar_menu', 'rew_add_bbp_profile', 999);
    }
     
     
    function rew_admin_bar_remove_wp_profile() {
            global $wp_admin_bar;
    
            /* **edit-profile is the ID** */
            $wp_admin_bar->remove_menu('edit-profile');
     }
     
    
    function rew_add_bbp_profile($wp_admin_bar) {
    	
    			$current_user = wp_get_current_user();
    			$user=$current_user->user_nicename  ;
    			$user_slug =  get_option( '_bbp_user_slug' ) ;
    			if (get_option( '_bbp_include_root' ) == true  ) {	
    				$forum_slug = get_option( '_bbp_root_slug' ) ;
    				$slug = $forum_slug.'/'.$user_slug.'/' ;
    			}
    			else {
    				$slug=$user_slug . '/' ;
    			}
    			
    			$profilelink = '/' .$slug. $user . '/edit' ;
    			
    			$wp_admin_bar->add_node( array(
    				'parent' => 'user-actions',
    				'id'		=> 'bbp-edit-profile',
    				'title' => 'Edit Profile',
    				'href' => $profilelink,
    			) );
    
    }

    madflute
    Participant

    @madflute

    Worked like a charm! Thank you so so so much! I am in a happy place!


    Robin W
    Moderator

    @robin-w

    great – glad to have helped.

Viewing 16 replies - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.
Skip to toolbar