rtmedia_privacy_levels Filter, Modify Privacy Levels

My goal is to remove “Public” and “Private”. Reference link: https://rtmedia.io/docs/developers/hooks/filter-to-modify-default-privacy-options/

I putted it in my theme function.php this code, and it doesn’t work.

add_action( 'plugins_loaded', 'custom_plugin_plugins_loaded', 10 );

function custom_plugin_plugins_loaded(){
add_filter( 'rtmedia_privacy_levels', 'custom_rtmedia_privacy_levels',10,1 );
}
 
 function custom_rtmedia_privacy_levels( $privacy_settings ) {
    $privacy_settings = [
    'levels' => [
        40 => esc_html__( 'Private - Visible only for allowed users', 'custom' ),
        20 => esc_html__( 'Public - Visible to registered users', 'custom' ),
        ]
    ];
return $privacy_settings;
}

Any ideas?

Hello @Keybeth_Ortiz,

If you want to remove Public and Private privacy options and want to keep only Logged in users then you will need to remove them from the Privacy levels array too.

Meaning you will only need to keep the logged in users level in the array by using above action.

For Example :

add_action( 'plugins_loaded', 'my_custom_plugin_plugins_loaded', 10 );

function my_custom_plugin_plugins_loaded(){
    add_filter( 'rtmedia_privacy_levels', 'custom_rtmedia_privacy_levels', 10, 1 );
}

function custom_rtmedia_privacy_levels( $custom ) {
        $custom = array(
        'levels' => array(
            20 => 'Logged in Users - Visible to registered users',
            )
        );
    return $custom;
}

Let us know if you still face any issue. Thank you.

Hi @pranalipatel, I did it, but i tried to put my code in the funtions.php in my child-theme. Then I moved it to bp-custom.php file and now it is working!!!

add_action( 'plugins_loaded', 'ra_plugin_plugins_loaded', 10 );

function ra_plugin_plugins_loaded(){
add_filter( 'rtmedia_privacy_levels', 'ra_media_privacy_levels',10,1 );
}

function ra_media_privacy_levels($privacy_settings){
return  [
    'levels' => [
        40 => __( 'Private - Visible only for allowed users', 'custom' ),
        20 => __( 'Public - Visible to registered users', 'custom' ),
        ]
];

}

Hello @Keybeth_Ortiz,

Yes, as mentioned in the document the above action will need to put under bp-custom.php file.

We are glad to know that your issue has been solved.

We are closing this thread for now. Feel free to create new if you need any assistance.

Thank you.