Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add a logout option in TABS,


  • kjhjkhjk
    Participant

    @snorlax775

    Hello, how can I add a logout option for users in the default tabs for login members?

    I ask because when someone is visiting the site from a mobile, I saw very difficult to log out the session from a mobile, so If I can add a logout option in tabs menu that would be great.

    Thanks

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

  • Venutius
    Moderator

    @venutius

    You could add the following to your functions.php:

    add_action( 'bp_setup_nav', 'bpex_logout_tab', 50 );
    
    function bpex_logout_tab() {
    	
    	if ( ! bp_is_user_profile() && ! bp_is_user_activity() && ! bp_is_user() ) {
    		return;
    	}
    	
    	bp_core_new_nav_item( array(
    				'name'                => __( 'Log Out', 'buddypress' ),
    				'slug'                => 'logout',
    				'position'            => 99,
    				'screen_function'     => 'bpex_wp_logout',
    				'default_subnav_slug' => 'public',
    				'item_css_id'         => 'logout-tab'
    	) );
    	
    }
    
    function bpex_wp_logout() {
    	wp_logout();
    	wp_redirect( home_url() );
    }

    kjhjkhjk
    Participant

    @snorlax775

    Hey that works perfectly, thanks man!

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