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.

Connect Users and Taxonomies

I came across a tutorial about ‘Custom User Taxonomies in WordPress‘ and there is a plugin based on that ‘User Taxonomies‘ but these are for creating taxonomies for Users. Have a read thought the tutorial it might help. I think what you’re talking about is to associating posts’ taxonomies with users. I think you need … Read more

Check if WP_User_Query ‘include’ is empty

I think the problem here is that in the process of violating this rule, you’ve created confusion and problems: do 1 thing per statement, 1 statement per line Coupled with another problem: Passing arrays to the APIs which get stored as serialised PHP ( security issue ) And another: Always check your assumptions it ignores … Read more

Show Biographical Info while creating new user

No. There are no hooks or filters to add an input field to the create user form. Maybe it is possible to add an input field via jQuery. I have not tested it. If it is pssible to add an input field, than it should be possible to save this information because the process of … Read more

Validating a new user registration field

After examining the code and much trial and error, I have a solution: There is a filter – user_profile_update_errors – that is called in the file wp-admin/includes/user.php just after WordPress does it’s own input validation. This filter allows plugins to return their own errors by adding them to a referenced WP_Error class. If any errors … Read more

WP_User_Query with combined meta query – not working?

It looks like you’re using wrong parameters, please try this instead (untested): $q = new WP_User_Query( array( ‘role’ => ‘contributor’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘first_meta’, ‘value’ => ‘2’, ), array( ‘key’ => ‘second_meta’, ‘value’ => ”, ‘compare’ => ‘!=’ ) ) ) ); where we’ve used the key, value and … Read more

If Else Gravatar Author Picture

You need to use get_the_author_meta() instead of the_author_meta() <?php $authorpic = get_the_author_meta(‘author_pic’); if ($authorpic) echo $authorpic; else echo get_avatar( get_the_author_email(), ’80’ ); ?>

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