I have a "barbershop" custom post type and i want to have a "barber" role in my wordpress. I wrote this code so my barber would have access to write or delete his own barbershop.

// Barbershop Post Type
function register_barbershop() {
    $labels = array(
        'name'                                  =>  __('آرایشگاه ها', 'noosh'),
        'singular_name'                         =>  __('آرایشگاه', 'noosh'),
        'add_new'                               =>  __('افزودن', 'noosh'),
        'add_new_item'                          =>  __('افزودن آرایشگاه تازه', 'noosh'),
        'edit_item'                             =>  __('ویرایش آرایشگاه', 'noosh'),
        'new_item'                              =>  __('آرایشگاه تازه', 'noosh'),
        'view_item'                             =>  __('نمایش آرایشگاه', 'noosh'),
        'view_items'                            =>  __('نمایش آرایشگاه ها', 'noosh'),
        'all_items'                             =>  __('همه ی آرایشگاه ها', 'noosh'),

    $args = array(
        'labels'                                =>  $labels,
        'public'                                =>  true,
        'capability_type'                       =>  'bshop',
        'map_meta_cap'                          =>  true,
        'supports'                              =>  array('title', 'editor', 'comments', 'author', 'thumbnail')
    register_post_type('barbershop', $args);

add_action( 'init', 'register_barbershop' );

// Add barber user role
function add_barber() {
    $caps = [
        'read'                    => true,
        'edit_bshop'              => true,
        'read_bshop'              => true,
        'delete_bshop'            => true,

        'edit_bshops'             => true,
        'edit_others_bshops'      => false,
        'publish_bshops'          => true,
        'read_private_bshops'     => true,

        'delete_bshops'           => true,
        'delete_private_bshops'   => true,
        'delete_published_bshops' => true,
        'delete_others_bshops'    => false,
        'edit_private_bshops'     => true,
        'edit_published_bshops'   => true,

    add_role( 'barber', 'آرایشگر', $caps );

add_action( 'after_setup_theme', 'add_barber' );

But there is one problem, just only my barber has access to this barbershop cpt, not superadmin. I want that my admin can manage the barbershop too, what should i do?

1 Answer 1


I think you should add these new capabilities to the admin role too.

Maybe this question would help you: Apply custom role capabilities to administrator (without plugin)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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