I have a custom role that allows access to only a sigle custom post type. This is all well and good, but now it is only showing up for this role, not for admin and super admin. I'm having a hard time getting it to show up in the admin dashboard.
add_role( 'artists_relations', 'Artist Relations', array( 'post_artists' ) ); function add_theme_caps() { $role = get_role( 'artists_relations'); $role->add_cap('delete_artists'); $role->add_cap('delete_published_artists'); $role->add_cap('delete_others_artists'); $role->add_cap('edit_artists'); $role->add_cap('edit_published_artists'); $role->add_cap('edit_others_artists'); $role->add_cap('publish_artists'); $role->add_cap('read'); $role->add_cap('upload_files'); $role->add_cap('manage_artist_categories'); } add_action( 'admin_init', 'add_theme_caps'); works great. I tried many suggestions from the internet, but none worked. The latest attempt, though, looked like this
function add_admin_caps() { $role = get_role( 'administrator'); $role->add_cap('delete_artists'); $role->add_cap('delete_published_artists'); $role->add_cap('delete_others_artists'); $role->add_cap('edit_artists'); $role->add_cap('edit_published_artists'); $role->add_cap('edit_others_artists'); $role->add_cap('publish_artists'); $role->add_cap('read'); $role->add_cap('upload_files'); $role->add_cap('manage_artist_categories'); } add_action( 'admin_init', 'add_admin_caps'); I've read a few posts that mentioned removing filters. I don't understand why this would work for a new role but not let me augment an existing one. But isn't admin supposed to have rights to everything without having to specify it anyway?
-- EDIT -- (adding post type registration)
function register_artists_post_type() { register_post_type('artists',array( 'labels' => array( 'name' => __( 'Artists' ), 'singular_name' => __( 'Artists' ), 'add_new' => __( 'Add Artist','Artist' ), 'add_new_item' => __( 'Add New Artist' ), 'edit_item' => __( 'Edit Artist' ), 'new_item' => __( 'New Artist' ), 'view_item' => __( 'View Artist' ), 'search_items' => __( 'Search Artists' ), 'not_found' => __( 'No Artists Found' ), 'not_found_in_trash' => __( 'No Artists In Trash' ), 'parent_item_colon' => '' ), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'has_archive' => true, 'supports' => array( 'title','editor','excerpt','custom-fields','thumbnail' ), 'rewrite' => array('slug' => 'artists','with_front' => false), 'taxonomies' => array('large_feature','small_feature'), 'capability_type' => 'post', 'hierarchical' => false, 'capabilities' => array( 'publish_posts' => 'publish_artists', 'edit_posts' => 'edit_artists', 'edit_others_posts' => 'edit_others_artists', 'delete_posts' => 'delete_artists', 'delete_others_posts' => 'delete_others_artists', 'read_private_posts' => 'read_private_artists', 'edit_post' => 'edit_artists', 'delete_post' => 'delete_artists', 'read_post' => 'read_artists', 'manage_categories' => 'manage_artist_categories', ) )); } add_action('init','register_artists_post_type');
register post type