Capibilities of CPT WordPress

Adding custom capabilities should use the ‘admin_init’ hook. Your function can look like this: function add_bounty_product_caps() { $role = get_role( ‘mmv_multi_vendor’ ); $role->add_cap( ‘edit_crea_resi’ ); $role->add_cap( ‘edit_crea_resis’ ); $role->add_cap( ‘edit_others_crea_resis’ ); $role->add_cap( ‘publish_crea_resis’ ); $role->add_cap( ‘read_crea_resi’ ); $role->add_cap( ‘read_private_crea_resis’ ); $role->add_cap( ‘delete_crea_resi’ ); $role->add_cap( ‘edit_published_crea_resis’ ); $role->add_cap( ‘delete_published_crea_resis’ ); $role->add_cap( ‘edit_crea_spedizioni’ ); $role->add_cap( ‘edit_crea_spedizionis’ ); … Read more

Capability to edit post slugs

If it’s supposed to edit its own post only, make it with author‘s capabilities. If it should edit posts of other users, as well, make it with editor‘s capabilities. Case 1 function wpse_add_your_role() { $role = get_role( ‘author’ ); if ( ! empty( get_role( ‘your_role’ ) ) ) { remove_role( ‘your_role’ ); } add_role( ‘your_role’, … Read more

How can I create multiple different admin roles with their own capabilities

Yes it’s very easy. You’ll want to use the add_role() function to add your custom roles – https://codex.wordpress.org/Function_Reference/add_role Then you can use add_cap to add custom capabilities – https://codex.wordpress.org/Function_Reference/add_cap One important thing to mention is that both add_role and add_cap are saved to the database so they only need to run 1x so it’s good … Read more

Removing add new pages form editor role

Ok so few things.. there’s a pretty well coded plugin that handles user roles and permissions: https://wordpress.org/plugins/user-role-editor/ If you’d like to do this programatically though, you should: <?php function wpcodex_set_capabilities(){ global $wp_roles; // global class wp-includes/capabilities.php $role=”editor”; $cap = ‘publish_pages’; $wp_roles->remove_cap( $role, $cap ); } add_action( ‘init’, ‘wpcodex_set_capabilities’ ); ?> Lmk if that does it … Read more