How to loop through each user id?
How about using get_users()? You probably don’t even need parameters for it, default behavior should be just what you’re looking for.
How about using get_users()? You probably don’t even need parameters for it, default behavior should be just what you’re looking for.
The function’s arguments are as follows: user ID, custom field name (meta key), data return method (optional). So if you wanted to grab data in usermeta with the key of ‘member_zip_code’, you would run: get_user_meta( $user_id, ‘member_zip_code’, true ); Alternatively, in your prior method, you could grab the additional data like this: $data = get_user_meta … Read more
You can use the following function: function get_user_id_by_display_name( $display_name ) { global $wpdb; if ( ! $user = $wpdb->get_row( $wpdb->prepare( “SELECT `ID` FROM $wpdb->users WHERE `display_name` = %s”, $display_name ) ) ) return false; return $user->ID; } This is the same code get_user_by() uses, but since that function only allows ID, slug, email or login … Read more
Okay.. you COULD add a button like you mentioned; but I think this is going to require a lot more code. The users.php page is using the WP List Table class.. which means we can hook into the bulk actions and add our custom value there. So, let’s create a function to add a new … Read more
you can try this code $args = array( ‘meta_query’ => array( array( ‘key’ => ‘score’, ‘value’ => 0, ‘compare’ => ‘>’, ‘type’ => ‘numeric’ ) ), ‘orderby’ => ‘meta_value_num’, ‘number’ => 20 ); $suggested_user_query = new WP_User_Query( $args ); $users = $suggested_user_query->get_results(); echo ‘<div id=”user_suggest”>’; echo ‘<ul>’; foreach ($users as $user) { // get all … Read more
If I did understand well, we need to cache a value retrieved from another REST service, from the login to logout of the user on the wordpress installation, so we will hook into this wp_login to get the value and cache it using Transient API, Options API or a persistent caching plugin. add_action(‘wp_login’, ‘my_get_and_cache_rest_value’); function … Read more
To add a field to the profile/user edit page you need to use the edit_user_profile hook and show_user_profile hook so: add_action( ‘show_user_profile’, ‘my_extra_user_fields’ ); add_action( ‘edit_user_profile’, ‘my_extra_user_fields’ ); function my_extra_user_fields( $user ) { ?> <h3>User avatar</h3> <table class=”form-table”> <tr> <th><label for=”user_avatar”>User avatar</label></th> <td> <input id=”user_avatar” name=”user_avatar” type=”text” value=” <?php $user_avatar = get_the_author_meta( ‘user_avatar’, $user->ID ); … Read more
Although the readonly attribute can be removed using Chrome/Firebug inspector (making the field editable again), much probably the average user will not know this. <?php function wpse50730_script_enqueuer(){ if(current_user_can(‘subscriber’)) { echo ‘<script type=”text/javascript”> jQuery(document).ready( function($) { $(“.form-table #email”).attr(“readonly”, true); }); </script>’; } } add_action(‘admin_head-profile.php’, ‘wpse50730_script_enqueuer’);
I suspect that the problem lies in the priority of the profile_update action. You are using priority 10, which is also the default priority. The WP-Members plugin updates custom user meta fields using this same hook, also at the default priority. So, the plugin’s update is likely happening after your process. (This is probably why … Read more
Unfortunately this isn’t possible. Custom actions cannot be added to the bulk actions dropdown (see trac tickets: http://core.trac.wordpress.org/ticket/12732 and http://core.trac.wordpress.org/ticket/16031). For posts you can use the restrict_manage_posts hook to create another drop-down / add buttons to trigger your custom action. But there is no restrict_manage_* hook available for the user table. So the only (and … Read more