Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] remove or add Label to Select options visibilty "Everybody"


  • emidio007
    Participant

    @emidio007

    Hello,

    I would like to insert two new select options.
    e.g. anyone, Only Me, My Friends ..etc, I also want to remove one of the select options.

    The function “function setup_globals” in bp xprofile-Loader.php

    ‘public’ => array(‘id’ => ‘public’,
    ‘label’ => _x( ‘Everyone’, ‘Visibility level setting’, ‘buddypress’ )
    ….. )
    Is it possible to override the function as usual with a new function in functions.php bp? Or, for example, to remove one of the available options Select (Everybody)?

    i can’t send a Link to my Website, because i develop it at first on my localhost

    Thanks in advance

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

  • danbp
    Moderator

    @danbp

    Is it possible to override the function as usual ?

    No, not as usual. setup_globals function is part of a class, you have to extend the class.

    See better in bp-xprofile-function.php to get some filters.

    If the goal is to define user types, you can try this plugin or at least study his code to find a way to achieve your customization.

    Or much more simple, define the visibility level and disallow changes.


    emidio007
    Participant

    @emidio007

    hello danbp,

    thank you for your reply.

    I want to give the user the ability to choose between two options.
    e.g. “My Friends” and “Only Me”

    Maybe I could override these options with a filter.


    danbp
    Moderator

    @danbp

    Try this (add to bp-custom.php):

    function bpfr_remove_visibility_level( $levels ) {
    	global $bp;
    
    		if ( isset( $levels['loggedin'] ) ) {
    			unset( $levels['loggedin'] );
    		}
    
    		if ( isset( $levels['public'] ) ) {
    			unset( $levels['public'] );
    		}
    	return $levels;
    }
    add_filter( 'bp_xprofile_get_visibility_levels', 'bpfr_remove_visibility_level' );

    emidio007
    Participant

    @emidio007

    Thank you very much! It works great exactly as I had imagined.


    emidio007
    Participant

    @emidio007

    I am sending the code, if someone is looking for such solution.

    I added a line to the Filter. I wanted to modify directly the text “Only Me”.

    $levels['adminsonly']['label'] = _x( 'only visible for me', 'Visibility level setting', 'buddypress' );

    function bpfr_remove_visibility_level( $levels ) {
    	global $bp;
    
    		if ( isset( $levels['loggedin'] ) ) {
    			unset( $levels['loggedin'] );
    		}
    
    		if ( isset( $levels['public'] ) ) {
    			unset( $levels['public'] );
    		}
    $levels['adminsonly']['label'] =  _x( 'only visible for me', 'Visibility level setting', 'buddypress' );
    	return $levels;
    }
    add_filter( 'bp_xprofile_get_visibility_levels', 'bpfr_remove_visibility_level' );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] remove or add Label to Select options visibilty "Everybody"’ is closed to new replies.
Skip to toolbar