current_user_can( ‘edit_user’ ) does not work
current_user_can( ‘edit_user’ ) does not work
current_user_can( ‘edit_user’ ) does not work
In addition to the code piece in the question, 1. To display only the author roles in the user list page of editor: add_action(‘pre_user_query’,’editors_edit_author_list’); function editors_edit_author_list($user_search) { $user = wp_get_current_user(); if($user->ID != 1) { $user_meta=get_userdata($user->ID); //$user_roles= $user_meta->roles; global $wpdb; if(in_array(‘editor’, $user_meta->roles)) { $user_search->query_where = str_replace( ‘WHERE 1=1’, “WHERE 1=1 AND {$wpdb->users}.ID IN ( SELECT {$wpdb->usermeta}.user_id … Read more
if you are using the code from the thread you linked to, to disable the comments on post and pages then when a new post/page is added it should have the comments automatically disabled. The existing posts/pages will have comments enabled unless you uncheck the “Allow comments” checkbox when editing a post. A quick and … Read more
Allow contributor user role to perform copy operation PHP
How to give plugin access to specific role(s)
The problem is that wp_get_current_user (which current_user_can relies upon) is pluggable, which means it isn’t loaded until after plugins are loaded (to give plugins a chance to override it). That means it’s not available to call from the top level of a plugin file. Instead, I’d make the role check inside the hook e.g. function … Read more
How can restrict certain users from delete a category but can view only in wordpress?
User role and capablities only for 1 plugin
CPT requires manage_options and edit_posts for some reason
See which user role / capability is needed to use a plugin