Hide Specific User Page

I’m assuming you want to hide the author page on the site itself (and not in wp-admin). To do that, just create a new template file called author-{$id}.php, where {$id} is replaced by the ID of the author you want to hide. So if the author ID is 6, the template file should be called … Read more

Prevent custom user role to add new pages

Post types in WordPress have a list of capabilities that govern permissions surrounding them. These are: edit_post read_post delete_post edit_posts edit_others_posts publish_posts read_private_posts read delete_posts delete_private_posts delete_published_posts delete_others_posts edit_private_posts edit_published_posts create_posts Internally each post type matches these to the actual capabilities that can be given in WordPress. Most of the time these have the exact … Read more

Users Role and Access

What you need first is to understand User Roles in WordPress. Then a plugin to manage custom user roles, like User Role Editor or Members. In the administrative menu Settings > General, set the default role when a user registers to your custom role: The plugin Members has more advanced features, but case you were … Read more

How to Orderby User Role?

This one’s a little difficult, as there’s no default user role meta key or post data. The only thing we got is the user ID. // Get the posts $posts_by_author_ID = get_posts( array( ‘post_type’ => ‘post’ ,’post_status’ => ‘publish’ ,’orderby’ => ‘post_author’ ,’order’ => ‘DESC’ ) ); foreach ( $posts_by_author_ID as $post ) { static … Read more

I am adding a new class to my body tag if the logged in user is subscriber, need help

Please try this code instead- add_filter( ‘body_class’, ‘wpse_268176_body_class’ ); function wpse_268176_body_class( $classes ) { $user = wp_get_current_user(); if ( in_array( ‘subscriber’, $user->roles ) ) { $classes[] = ‘class-name’; // your custom class name } return $classes; } Place this in your active theme’s functions.php file. [Thanks Dave Romsey for your suggestion.]