Adding multiple user roles dynamically
Adding multiple user roles dynamically
Adding multiple user roles dynamically
Editor and contributor roles not correct after adding function
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
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
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
Yes. You can create a new role and enable specific capabilities. http://codex.wordpress.org/Function_Reference/add_role http://codex.wordpress.org/Function_Reference/add_cap
You do not need to use raw SQL, WordPress already provides WP_User_Query, and even provides examples of date based queries, for example the official docs say that this will retrieve all users registered within the last 12 hours: $args = array( ‘date_query’ => array( array( ‘after’ => ’12 hours ago’, ‘inclusive’ => true ) ) … Read more
Custom Post Types will be much easier to set up, and you won’t have to code your own solution to check in the Editor whether the current user has permission to create a new page or edit something. You can set up the CPT archives at whatever URL you like. So, in your example, you … Read more
You’ll want to use get_user_by(), which will return a WP_USER object which contains roles and capabilities. More info here. $user = get_user_by( ‘login’, ‘username’); $roles = $user->roles // this will contain an array of the roles the user is in
You can display user posts using user’s ID. This code might provide a quick sample on how to do it (I have not tested the code). $user_id = $_GET[‘author_id’]; //The Query query_posts(“author={$user_id}”); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); echo “<br>”; endwhile; else: echo “No Posts!”; endif; //Reset … Read more