Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In my plugin I have created a custom post type and defined capabilities for both the subscriber and the administrator role.

When I go into the backend and look at the capabilities that are in the list of capabilities for the administrator role, all the capabilities I added are checked.

However if I login as admin and try to move a post of type 'pp_zoekertje' to trash, wordpress tells me I am not allowed to do so.

I have of course, searched on stackexchange and various other sites but the only solutions I can find are telling me to do exactly what I am already doing.

Any help is appreciated.

function create_pp_zoekertje_post_type(){
register_post_type('pp_zoekertje',
    array(
        'labels' => array(
            'name' => 'Zoekertjes',
            'singular_name' => 'Zoekertje',
            'add_new' => __('Nieuw Zoekertje'),
            'add_new_item' => __( 'Nieuw Zoekertje' ),
            'edit' => __( 'Bewerk' ),
            'edit_item' => __( 'Bewerk Zoekertje' ),
            'new_item' => __( 'Nieuw Zoekertje' ),
            'view' => __( 'Bekijk' ),
            'view_item' => __( 'Bekijk Zoekertje' ),
            'search_items' => __( 'Zoek Zoekertjes' ),
            'not_found' => __( 'Geen zoekertjes gevonden' ),
            'not_found_in_trash' => __( 'Geen zoekertjes gevonden in prullenbak' ),
            ),
        'public' => true,
        'has_archive' => true,
        'show_ui' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'hierarchical' => false,
        'query_var' => true,
        'supports' => array(
            'title',
            'editor',
            'revisions',
        ),
        'map_meta_cap' => true,
        'capability_type' => 'pp_zoekertje',
        'capabilities' => array(
            'edit_post' => 'edit_pp_zoekertje',
            'edit_posts' => 'edit_pp_zoekertjes',
            'edit_others_posts' => 'edit_others_pp_zoekertjes',
            'publish_posts' => 'publish_pp_zoekertjes',
            'edit_published_posts' => 'edit_published_pp_zoekertjes',
            'read_post' => 'read_pp_zoekertje',
            'read_private_posts' => 'read_private_pp_zoekertjes',
            'delete_post' => 'delete_pp_zoekertje',
            'delete_others_posts' => 'delete_others_pp_zoekertjes'
        ),
//            'taxonomies' => array('pp_zoekertje_taxonomy','category'),
    )
);

$subscriber_role = get_role('subscriber');
$subscriber_role->add_cap('edit_pp_zoekertje');
$subscriber_role->add_cap('edit_pp_zoekertjes');
$subscriber_role->add_cap('publish_pp_zoekertjes');
$subscriber_role->add_cap('read_pp_zoekertje');
$subscriber_role->add_cap('read_private_pp_zoekertjes');
$subscriber_role->add_cap('delete_pp_zoekertje');
}

function poppunt_classifieds_search_Init() {
    create_pp_zoekertje_post_type();
    if (!is_admin()) {
        wp_enqueue_script('jquery');
        wp_enqueue_script( 'poppunt-classifieds-handlebars', plugins_url( '/js/handlebars.js', __FILE__ ));
    }
}
add_action('init', 'poppunt_classifieds_search_Init');

add_action('admin_init', 'plugin_admin_init');
function plugin_admin_init(){
    $administrator_role = get_role('administrator');
    $administrator_role->add_cap('edit_pp_zoekertje');
    $administrator_role->add_cap('edit_pp_zoekertjes');
    $administrator_role->add_cap('edit_others_pp_zoekertjes');
    $administrator_role->add_cap('publish_pp_zoekertjes');
    $administrator_role->add_cap('read_pp_zoekertje');
    $administrator_role->add_cap('read_private_pp_zoekertjes');
    $administrator_role->add_cap('delete_pp_zoekertje');
    $administrator_role->add_cap('edit_published_pp_zoekertjes');
    $administrator_role->add_cap('delete_others_pp_zoekertjes');

    register_setting( 'pp_options', 'pp-options', 'pp_plugin_options_validate' );

    add_settings_section('pp_options_main', 'Algemene instellingen', 'pp_options_main_output', 'pp_options_menu');

    add_settings_field(
        'pp_zoekertjes_option_input_page',
        __('Pagina met invulformulier voor zoekertje (toevoegen/bewerken)'),
        'pp_zoekertjes_option_input_page',
        'pp_options_menu',
        'pp_options_main');

    add_settings_field(
        'pp_zoekertjes_option_my_ads_page',
        __('Mijn zoekertjes pagina'),
        'pp_zoekertjes_option_my_ads_page',
        'pp_options_menu',
        'pp_options_main');
}
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.