Allow contributor to view own scheduled post

You can write your query for listing scheduled posts as follow : You can see the details here $the_query = new WP_Query(array( ‘post_status’ => ‘future’, ‘posts_per_page’ => 3, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’ )); To show the scheduled post on details page you should do something like this Add code to your theme’s functions.php … Read more

Dynamic homepage according to user role

To use a different page’s content on the homepage based on a logged-in user’s role you can do this: In your functions.php file add this code: function wpse_273872_pre_get_posts( $query ) { if ( $query->is_main_query() && is_user_logged_in() ) { //work-around for using is_front_page() in pre_get_posts //known bug in WP tracked by https://core.trac.wordpress.org/ticket/21790 $front_page_id = get_option(‘page_on_front’); $current_page_id … Read more

Is there a way to set the user Role based on email domain

With this code, you will check during the registration the users email and attach the roles you want to: <?php add_action( ‘user_register’, ‘wp234_set_role_by_email’ ); function wp234_set_role_by_email( $user_id ){ $user = get_user_by( ‘id’, $user_id ); $domain = substr( strrchr( $user->data->user_email, “@” ), 1 ); //Get Domain $contributor_domains = array( ‘gmail.com’ ); if( in_array( $domain, $contributor_domains ) … Read more

Allow Content Author to Publish, But Not Edit or Delete

I would create a new user role, and then assign that role to the user when you create their account. In your functions.php: add_role(‘content_writer’, ‘Content Writer’, array( ‘read’ => true, ‘publish_posts’ => true, ‘edit_posts’ => false, ‘delete_posts’ => false, )); You can see the codex for an additional listing of available roles and capabilities.

Why is wp-login redirecting to the home page when I use this function?

So, first off, if you want to block access to wp-admin, why hook into something that fires on every page load? Hook into admin_init instead. And, as @MattSmath mentioned, edit isn’t a capability. edit_posts is. Also, admin_init only fires on admin pages, so you can remove is_admin() from your check. Your revised function: <?php add_action(‘admin_init’, … Read more

How to order posts by custom WP role?

you can add a custom field to each listing post with the user’s role and then in your query you can order by that field, for example say you have a custom field named `u_role’ then your query should look like this: $custom_role_query = new WP_Query( array( ‘author’ => implode( ‘,’, $custom_ids ), ‘post_type’ => … Read more

Include Author profile in search results

If you have a user role called “consultant” and you do a search filtering by capability “consultant”, you wouldn’t find anything. Roles and capabilities are different things. Here is the codex reference: http://codex.wordpress.org/Roles_and_Capabilities

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