How can I add capability to multiple roles?
How can I add capability to multiple roles?
How can I add capability to multiple roles?
I am not sure if there is something native. However you could get really hacky if you wanted to if no other option. You could create a css class to be inserted based on the current user role that is logged in. Then target that role (being sales for example) and hide that form field. … Read more
I assume you’re using wp_insert_post() to create the private page for the user. The function returns the ID of the created page. You can use this ID as part of a custom capability you grant to the user. // create the new $user // create private page $private_page_id = wp_insert_post( $postarr, $wp_error = false ); … Read more
Delete admin edit/delete links in users list wordpress admin
Author Error “Sorry, you are not allowed to access this page.”
To query posts with more than one author ID, you can use author__in parameter. This makes posts from chosen authors visible (read only) for the current user. add_filter(‘pre_get_posts’, ‘posts_for_current_author’); function posts_for_current_author($query) { if ( $query->is_admin && ‘edit.php’ === $GLOBALS[‘pagenow’] && ! current_user_can( ‘edit_others_posts’ ) ) { $query->set(‘author__in’, array(get_current_user_id(), 1, 2, 3) ); // add 1 … Read more
How to only display all posts to a custom User Role?
i think this might work with you function myshortcode(){ $user = wp_get_current_user(); if ( !in_array( ‘author’, (array) $user->roles ) ) { //Run shortcode } } add_shortcode(‘myshortcode’,’myshortcode’);
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