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

Create relationships between users or user roles

For functionality like this I think you’ll have to go with premium plugins or code it yourself. If you want to go with custom code Pods might be able to help you out with creating relationships between doctors and patients: https://wordpress.org/plugins/pods/

How to avoid duplicate users when I am using get_users?

I think it’s arguments issue. I recommend not to use role & role__not_in together rather either use only role OR use role__in & role__not_in combination. Also check your role param spelling. (see more on role) 2ndly orderby param rand is not valid according to codex (see here) so use proper param.

How to query users by post count no less than 10

I can see in your code you did mistakes with meta key arguments. You must use underscore instead of hyphen sign. Here is corrected code: $args = array( ‘number’ => 5 , ‘meta_key’ => ‘post_count’, ‘meta_value’ => 10, ‘meta_compare’ => ‘>’, ‘orderby’ => ‘rand’ ); $user_query = new WP_User_Query( $args ); if ( ! empty( … Read more

How to query 5 users in random who have published more than 10 posts

I tried this code and it should work for you In your function.php to make random order available in WP_User_Query function my_random_user_query( $class ) { if( ‘rand’ == $class->query_vars[‘orderby’] ) $class->query_orderby = str_replace( ‘user_login’, ‘RAND()’, $class->query_orderby ); return $class; } add_action( ‘pre_user_query’, ‘my_random_user_query’ ); Source And a query like this // Get all users id … Read more

How to display particular categorie’s post which associated to specific user?

How are you associating users to a post? If you meant users as post authors you can try pre_get_posts hook. function user_author_pre_get_posts( $query ) { $user_id = get_current_user_id(); // Get logged in user ID or pass specific user ID here if ( ( $query->is_author() || $query->is_category() ) && $query->is_main_query() ) { $query->set( ‘author__in’, $user_id ); … Read more

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