• I’m having issues assigning custom capabilities for custom post types to custom roles in the WordPress admin. The markup works for one post type but not others.

    Let me explain a little… I’ve created multiple custom post types (Jobs, Clients & Account Managers). I’ve also created custom user roles (Candidates, Account Managers, Job Authors).

    I’ve added custom capabilities for each of the post types and assigned all these to the administrator role & just some to each of the custom user roles.

    For example, only the Job Author can create jobs but all custom user roles can…

    $role->add_cap( 'delete_jobs' );
    $role->add_cap( 'edit_jobs' );
    $role->add_cap( 'edit_others_jobs' );
    $role->add_cap( 'manage_jobs' );
    $role->add_cap( 'read_private_jobs' );

    This works fine when logged in as each user type. However, when I try to do similar to the Candidates & Account Managers post type, then I receive the error “You do not have sufficient permissions to access this page.” when trying to view /wp-admin/edit.php?post_type=client or /edit.php?post_type=account-manager

    The only way around this is to include $role->add_cap( ‘create_clients’ ) or $role->add_cap( ‘create_account_managers ), but we don’t want users at this level to be able to create content, only administrators. Administrators can view, edit & create content for all content types without any problem.

    The markup is the same for each post type & role except for the relevant names so I don’t understand why the Jobs post type should work as expected but the other two don’t.

    Any body had issues similar to this or know where I could be going wrong?

  • The topic ‘Problem assigning Custom User Roles to Custom Post Type’ is closed to new replies.