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

Not able to post data through wp-admin

I recommend to try by debugging the code, might be there is an issue because of a New version of PHP. Try by writing this code into the wp-config.php file and see what if any error: // Enable WP_DEBUG mode define( ‘WP_DEBUG’, true ); // Enable Debug logging to the /wp-content/debug.log file define( ‘WP_DEBUG_LOG’, true … Read more

Disabling user capability to edit_posts or delete_posts in the front-end

By using this functionality we can able to remove the delete option of the page or post. function wp_restrict_page_deletion( $caps, $cap, $user_id, $args ) { $post_id = $args[0]; if ( $cap === ‘delete_post’ && $post_id === your post id* ) { $caps[] = ‘do_not_allow’; } return $caps; } add_filter( ‘map_meta_cap’, ‘wp_restrict_page_deletion’, 10, 4 ); I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)