Ordering users of a specific role by last name

There is apparently an open ticket about this bug. Here is a workaround that I tested: $args = array( ‘meta_key’ => ‘last_name’, ‘role’ => ‘guest-teacher’ ); $wp_user_query = new WP_User_Query($args); $wp_user_query->query_orderby = str_replace( ‘user_login’, ‘wp_usermeta.meta_value’, $wp_user_query->query_orderby ); $wp_user_query->query(); $authors = $wp_user_query->get_results(); Problem with this is that it runs the query twice.

How to set individual capabilities on a taxonomy? Or how to re-register an existing taxonomy?

This should works add_action( ‘init’, ‘register_category_again’, 1 ); function register_category_again() { $user = wp_get_current_user(); if ( $user->roles[0] != ‘your_custom_role’ ) return; global $wp_taxonomies; unset( $wp_taxonomies[‘category’] ); global $wp_rewrite; $rewrite = array( ‘hierarchical’ => true, ‘slug’ => get_option(‘category_base’) ? get_option(‘category_base’) : ‘category’, ‘with_front’ => ! get_option(‘category_base’) || $wp_rewrite->using_index_permalinks(), ‘ep_mask’ => EP_CATEGORIES, ); register_taxonomy( ‘category’, ‘post’, array( … Read more

Editor role cannot save custom theme options

There’s a bug(ish) report regarding this here: http://make.wordpress.org/themes/2011/07/01/wordpress-3-2-fixing-the-edit_theme_optionsmanage_options-bug/ You can use a filter to modify the theme page capability. First you’ll want to edit your register_setting() calls to look like this: register_setting( ‘map-options’, ‘map_zoom’ ); register_setting( ‘map-options’, ‘map_longitude’ ); register_setting( ‘map-options’, ‘map_latitude’ ); The first parameter is the settings group and this is what we’re … Read more

Create user role restricted to specific CPT

You need to register the CPT with your custom capability, then assign that specific cap to the user. When passing the arguments to register_post_type, set capability_type to your new capability, so the check turns into ‘edit_cpts’ instead of ‘edit_post’. By setting ‘capability_type’ => [ ‘cpt’, ‘cpts’ ], ‘cpt’ will map to ‘post’ for standard capability … Read more

Do custom user roles have any default capabilities?

I’ve found that the WordPress has_cap() function, which is relied on by functions like user_can() and current_user_can, explicitly returns false for empty capabilities. Example: If a capability is passed as an argument using current_user_can(), this function will pass the capability to has_cap() and return the results: return call_user_func_array( array( $current_user, ‘has_cap’ ), $args has_cap() will … Read more

Allowing Custom Capability to Manage Plugin Options

If you use the Settings API, that $option_page is the value of a hidden <input> field generated by settings_fields(). For example: <input type=”hidden” name=”option_page” value=”{Option group name}”> So if you have settings_fields( ‘my-group’ ) in your code, then the $option_page would be my-group. See the (as of writing, 5th) note here. Code sample: (tried and … Read more

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