Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide Profile Group Tab from Admin if Level 1 (s2Member)


  • buckyb
    Participant

    @buckybeever

    Hello,

    I have 2 s2member levels, and quite a bit of groups for each level, it’s getting confusing for the admin when editing. I’d like to hide some of the groups from the admin in the EDIT section if the user is in a specific level.

    I found this below and tweaked it for s2member, but alas it doesn’t work LOL, if anyone can help, would greatly appreciate it!!

    // Hide profile group to admin based on Levels
    function bpfr_hide_profile_field_group( $retval ) {
    	if( current_user_is(administrator) && current_user_can("access_s2member_level1") ) {
               // exlude groups, separated by comma
    		$retval['exclude_groups'] = '6,5';          		
    	} 
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp
    Moderator

    @shanebp

    Please use the code when sharing code.

    current_user_xxx refers to the logged in user – not the displayed user.

    Use is_super_admin() to determine if the current user is a site admin.
    https://codex.wordpress.org/Function_Reference/is_super_admin

    $displayed_user_level = some_s2_function( bp_displayed_user_id() );
    if( is_super_admin() && $displayed_user_level == 'some level' ) )

    some_s2_function is whatever s2 function returns the member level based on a user_id.


    buckyb
    Participant

    @buckybeever

    Thank you for replying, I tried to figure it out on my own, but I cant get it to work. I changed some of the lines, and included what you have, but it breaks the site. (still learning, please bear with me)

    function bpfr_hide_profile_field_group( $retval ) {
    $displayed_user_level = some_s2_function( bp_displayed_user_id() ); 
    if( is_super_admin() && $displayed_user_level == 'access_s2member_level1' )  {
    // exlude groups, separated by comma
    		$retval['exclude_groups'] = '6,5';          		
    	} 
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide Profile Group Tab from Admin if Level 1 (s2Member)’ is closed to new replies.
Skip to toolbar