#5856
Vladimir
Keymaster

Hi Barry,

Thanks for the feedback.

URE does not include UI to turn ON for a role selected screen option (or in other words, show meta box). You can use this code though:


/**
 * Turn ON 'Slug' screen option for user with 'author' role at the Media Library item (attachment) edit page
 */
add_filter( 'hidden_meta_boxes', 'show_slug_metabox', 10, 3 );

function show_slug_metabox( $hidden, $screen, $use_defaults ) {

    if ( $screen->id!=='attachment') {
        return $hidden;
    }
    
    $user = wp_get_current_user();
    if ( empty( $user) || empty( $user->roles ) ) {
        return $hidden;
    }
    if ( !in_array( 'author', $user->roles ) ) {
        return $hidden;
    }
    
    $slug_key = array_search( 'slugdiv', $hidden );
    if ( $slug_key !== false ) {
        unset( $hidden[ $slug_key ] );
    }

    return $hidden;
}

Change ‘author’ to your own role ID and setup this code as a Must Use plugin.