How to hide a specific user role option in a user role list?

SOLUTION: // Remove Administrator role from roles list add_action( ‘editable_roles’ , ‘hide_adminstrator_editable_roles’ ); function hide_adminstrator_editable_roles( $roles ){ if ( isset( $roles[‘administrator’] ) && !current_user_can(‘level_10’) ){ unset( $roles[‘administrator’] ); } return $roles; }

Restrict backend but allow to use post.php?action=delete&post=POSTID from front-end

This will allow you to access post.php and still restrict the back-end. You need have action, action name as delete, post key and value, and wpnonce kay and value. Otherwise, it will redirect you to homepage. function disable_wp_admin() { if ( ! is_admin() ) return; if ( current_user_can( ‘manage_options’ ) ) return; if (( current_user_can( … Read more

Remove Adminstrator Hyperlink from a user having role to add and see users

I think something like this should work just fine: function my_views_users($args) { $hidden_role=”administrator”; // it will hide filter with role ‘administrator’ – you can change it to some other role $users_counts = count_users(); $total_users = $users_counts[‘total_users’] – $users_counts[‘avail_roles’][$hidden_role]; $args[‘all’] = “<a href=”https://wordpress.stackexchange.com/questions/97309/$url”$class>” . sprintf( _nx( ‘All <span class=”count”>(%s)</span>’, ‘All <span class=”count”>(%s)</span>’, $total_users, ‘users’ ), number_format_i18n( … Read more

How to add author role as a custom field to custom post type in wordpress?

You can hook into save_post_{$post->post_type} which fires after the post has been saved in database. function wpse405375_save_author_role_as_meta( $post_ID, $post, $update ) { //Get the User object from author id. $author = get_user_by( ‘ID’, $post->post_author ); //Get author roles $roles = $author->roles; //Store the role/roles in post meta /* This one will store all the roles … Read more

pre_get_posts Remove posts based on meta value with ‘post__not_in’

Try this version: // Get all posts with the access level of ‘Member’ function members_get_member_posts() { $post_ids = wp_cache_get( ‘wpse61487_members_posts’ ); if ( false === $post_ids ) { $post_ids = array(); $args=array( ‘post_type’ => ‘any’, ‘meta_key’ => ‘_members_access_role’, ‘meta_value’ => ‘member’, ‘post_status’ => array(‘publish’,’private’) ); $protected_posts = get_posts($args); if($protected_posts) { $post_ids = wp_list_pluck( $protected_posts, ‘ID’ … Read more

WordPress Super Admin

I would recommend creating a Custom User Role, using the add_role() function, such as a “Site Admin” or “Sub-Admin” (or whatever you want to call it). Then, you can assign specific user capabilities to that custom role, thereby giving users exactly the capabilities you want them to have, without giving them the capabilities you don’t … Read more

Restricting users to a specific front end page [closed]

You’d have to add a function during the init action of WP. There you’ll get the current user and check whether they have a specific role assigned to them and redirect to the page when they do. add_action(‘init’, function () { $user = wp_get_current_user(); $role=”your role”; if (in_array($role, $user->roles)) { wp_redirect(‘url’); } }); WordPress Function … Read more

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