Get Sticky User in user loop based on user role

If you read the code (in version 4.5.2 on line 164-173) you will see that orderby can be an array of values, coupled with order. So you could modify $args like this: $args = array( ‘orderby’ => array( array (‘sticky’ => ‘DESC’), array (‘registered’ => ‘DESC’)), ‘fields’ => ‘all_with_meta’, ); Note that I know nothing … Read more

Add new post only in assigned category

First remove the category metabox from the post edit screen for this particular role, let’s name it onecat-author: if (current_user_can(‘onecat-author’)) { remove_meta_box (‘category’, ‘post’, ‘normal’); } Next, when the post is saved use the available hook to assign the category: if (current_user_can(‘onecat-author’)) { add_action (‘save_post’, ‘wpse_231846_save_cat’, 10, 1 ); } function wpse_231846_save_cat ($post_id) { wp_set_post_categories … Read more

Editor role isn’t seeing specific post type posts with only post_type parameter

What you need to do is to make custom user meta fields. Links these metafields to a custom category linked to your custom post type. Use this code for a checkbox feeling: <input type=”checkbox” id=”category-<?php echo $post_type->term_id ?>” <?php if($user_cats[0] && in_array( $post_type->term_id, $user_cats[0] )) echo ‘checked=checked’;?> name=”categories[]” value=”<?php echo $post_type->term_id;?>”/> Every custom category you … Read more

Custom user roles

To add a role see: https://codex.wordpress.org/Function_Reference/add_role To add capabilities see: click add_cap link on the bottom A list of all caps see: https://codex.wordpress.org/Roles_and_Capabilities For all the roles you can also use them for different post types. if post type is “books” edit_pages -> edit_books. N.B.: This setting is saved to the database (in table wp_options, … Read more

Disable `create_post` for built-in post type

There is no built-in capability of create_post. Update: There is a capability create_posts but it’s not well publicised and also has issues surrounding it which I’m afraid I don’t have time to look into at the moment. There are already answers that might help: https://stackoverflow.com/a/3248103 https://wordpress.stackexchange.com/a/178059/94267 Original answer: There is publish_posts. You need to turn … Read more

How to update user role totals

You’ll also need to export the old site’s options table which is usually called wp_options and import it to new one. Cause in the options table aka wp_options table there is a row field called wp_user_roles and it holds the role values of the site.

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