Custom Fields
Re-Envisioned
Support MB Settings Page Allow non-Admin roles access to settings page Reply To: Allow non-Admin roles access to settings page

#12522

tom
Participant

For example, the default generated will show up for admins but not for non-admins.

add_filter( 'mb_settings_pages', 'prefix_options_page' );
function prefix_options_page( $settings_pages ) {

        $settings_pages[] = array(
            'id'          => 'customize',
            'option_name' => 'customize',
            'menu_title'  => 'customize',
            'icon_url'    => 'dashicons-admin-generic',
            'style'       => 'boxes',
            'columns'     => 1,

            'position'    => 168,
        );

        return $settings_pages;
}

I tried wrapping it like so, but still a no-show for non-admins:

add_filter( 'mb_settings_pages', 'prefix_options_page' );
function prefix_options_page( $settings_pages ) {

        $settings_pages[] = array(
            'id'          => 'customize',
            'option_name' => 'customize',
            'menu_title'  => 'customize',
            'icon_url'    => 'dashicons-admin-generic',
            'style'       => 'boxes',
            'columns'     => 1,

            'position'    => 168,
        );

if( current_user_can('editor') || current_user_can('administrator') ) {
            return $settings_pages;
}
}