0

I'm using Buddypress Extended Profile and the current visibility options are: - Everyone - Only Me - My Friends - All Members

I need to remove "My Friends" and "All Members" and just leave "Everyone" and "Only Me". After that I need to rename "Everyone" to "Public" and "Only Me" to "Private". I've been googling for hours now and no luck :( I can't find any hooks, filters or anything that could help me achieve this.

closed as off-topic by cybmeta, Pieter Goosen, Robert hue, Mayeenul Islam, TheDeadMedic Feb 16 '15 at 13:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

There's a filter for that: bp_xprofile_get_visibility_levels. It is used to filter an array of visibility levels, which is initialized like so:

$this->visibility_levels = array(
    'public' => array(
        'id'      => 'public',
        'label' => _x( 'Everyone', 'Visibility level setting', 'buddypress' )
    ),
    'adminsonly' => array(
        'id'      => 'adminsonly',
        'label' => _x( 'Only Me', 'Visibility level setting', 'buddypress' )
    ),
    'loggedin' => array(
        'id'      => 'loggedin',
        'label' => _x( 'All Members', 'Visibility level setting', 'buddypress' )
    )
);

if ( bp_is_active( 'friends' ) ) {
    $this->visibility_levels['friends'] = array(
        'id'    => 'friends',
        'label' => _x( 'My Friends', 'Visibility level setting', 'buddypress' )
    );
}

(the above code lives in bp-xprofile/bp-xprofile-loader.php)

So in your case you would go like:

add_filter(
    'bp_xprofile_get_visibility_levels',
    function($levels)
        {
        // remove "My Friends"
        if(isset($levels['friends'])) unset($levels['friends']);
        // remove "All Members"
        if(isset($levels['loggedin'])) unset($levels['loggedin']);
        // change "Everyone" to "Public"
        if(isset($levels['public'])) 
            $levels['public']['label']=_x('Public','Visibility level setting','buddypress');
        // change "Only Me" to "Private"
        if(isset($levels['adminsonly']))
            $levels['adminsonly']['label']=_x('Private','Visibility level setting','buddypress');
        return $levels;
        }
    );

Remember, it's a filter, and others may have hooked before you, so always check if a given array element isset().

As a side note, there are translation considerations here, but I guess elaborating on that would be out of scope.

Not the answer you're looking for? Browse other questions tagged or ask your own question.