edit_page or edit-pages for current_user_can()?

You can find list of capabilities here: Roles and Capabilities There is no capability called edit_post nor edit_page. But… There is also something called Meta Capabilities. The capabilities listed on the Capabilities list are global capabilities. So they’re saying that user can edit posts or pages. But it doesn’t mean that given user can edit … Read more

What’s the correct way to add capabilites to user roles?

The best place to add this would be in the plugin’s activation hook. You can either call the dynamic activate_{$plugin} hook, or better yet use the provided register_activation_hook method. Using your code example above – something like this would be what you’re looking for: register_activation_hook( __FILE__, function() { $role = get_role( ‘editor’ ); $role->add_cap( ‘edit_booked_appointments’, … Read more

WooCommerce which roles and capabilities control user login re-direct to Woo Account Page?

WooCommerce will only show the admin bar and give dashboard access to users who have the edit_posts or manage_woocommerce capabilities. If you don’t want to give users one of those capabilities, you can use the woocommerce_disable_admin_bar filter to give access and show the admin bar: add_filter( ‘woocommerce_disable_admin_bar’, function( $disable_admin_bar ) { if ( current_user_can( ‘my_capability’ … Read more