BuddyDev

Search

[Resolved] Hide tabs and profile for custom roles

Tagged: ,

  • Participant
    Level: Enlightened
    Posts: 53
    Jennifer on #26015

    Hi!

    I’ve been trying unsuccessfully with the following code:

    -Hide USER-MEDIA and WALL tabs for the role Subscriber and customer. (this code hiden in all profiles)
    and how do I hide the tab GROUP only in customer, do I duplicate the action?

    -Redirect to custom page when Im not logged when i see the page of subscriber´s profiles

    Thank you very much!!
    regards,
    Jennifer

    
    
    function bpfr_hide_activity_nav() {
    	$user_id = get_current_user_id();
    	$user    = wp_get_current_user();
    	if ( $user_id == in_array( 'subscriber', $user->roles ) or in_array( 'customer', $user->roles ) ) {
    
    		bp_core_remove_nav_item( 'user-media' );
    		bp_core_remove_nav_item( 'wall' );
    	}
    
    	return;
    }
    
    add_action( 'bp_ready', 'bpfr_hide_activity_nav', 110, 3 );
    
    function buddy_private( $redirect_to, $redirect_url_specified, $user ) {
    	$user_id = get_current_user_id();
    	if ( ! is_user_logged_in() && ( ( $user_id == in_array( 'subscriber', $user->roles ) or in_array( 'customer', $user->roles ) ) ) ) {
    		$redirect_to = 'https://example.com/';
    	}
    
    	return $redirect_to;
    }
    
    add_filter( 'login_redirect', 'buddy_private', 110, 3 );
    
    • This topic was modified 4 years, 5 months ago by Brajesh Singh. Reason: Removed url as requested
  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #26031

    Hi Jennifer,
    for the part 1(wall,user media), The code should work. If it is not, I will suggest reprting/asking to the plugin developers.

    For the second part(custom redirect).

    You may use the following code

    
    function bpc_redirect_for_no_logged() {
    	if ( bp_is_user() && ! is_user_logged_in() ) {
    		$redirect_url = site_url( '/' );// change it.
    		bp_core_redirect( $redirect_url );
    	}
    }
    
    add_action( 'bp_template_redirect', 'bpc_redirect_for_no_logged');
    
    

    Please make sure to change the redirect url.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 53
    Jennifer on #26083
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #26087
    This reply has been marked as private.

The topic ‘ [Resolved] Hide tabs and profile for custom roles’ is closed to new replies.

This topic is: resolved