How to display random users with avatars

I am not sure why your query is returning more IDs than necessary. The $args for get_users look correct. By default get_users does not support orderby=rand, but you can overwrite that option. See below: function random_user_query( &$query ) { $query->query_orderby = “ORDER BY RAND()”; } // Usage: [random_users how_many = 3] add_shortcode( ‘random_users’, ‘display_random_users’ ); … Read more

How to hide “Filter user list” from “All Users” screen

You can use the views_users filter to alter it. Here’s an example: /** * Remove the users view */ add_filter( ‘views_users’, ‘__return_empty_array’ ); if you want to remove it for every user. Here’s another example how you could remove it for non-admins (PHP 5.4+): /** * Remove the users view for non-admins */ add_filter( ‘views_users’, … Read more

How to update user role without logout

I think you are on the right track, wp_cache_delete was what finally helped me get an auto-signup with auto-login plugin working… I have this from there: wp_cache_delete($current_user->ID, ‘users’); wp_cache_delete($current_user->user_login, ‘userlogins’); Then see what roles you get after that with: $current_user = wp_get_current_user();

edit profile validation refreshes all field if missing wordpress

Approach 1, disable save button What you can do, is to prevent the user from saving the form if the required fields are not filled. This can be simply done via javascript. function require_fields_script(){ echo ” <script type=”text/javascript”> (function($){ $(‘#submit’).on(‘click’,function(e){ if (!$(‘#email’).val() || !$(‘#nickname’).val()){ e.preventDefault(); if (!$(‘#email’).val()) { window.alert(‘Please enter your email before saving.’); } … Read more

How can I import users into WordPress?

A new file, import.php: <?php define(‘WP_INSTALLING’, true); // this is required. i forget why! include ‘/path/to/wordpress/wp-load.php’; include ABSPATH . WPINC . ‘/registration.php’; // wp_insert_user() $userdata = array(‘user_login’ => ‘jdoe’, ‘user_pass’ => ‘foobar’); $user_id = wp_insert_user($userdata); Check wp_insert_user() for other possible fields. Run update_usermeta() for any additional needed meta fields. (Including user level, though there may … Read more

Get users with atleast one post

global $wpdb; $min_posts = 5; // Make sure it’s int, it’s not escaped in the query $author_ids = $wpdb->get_col(“SELECT `post_author` FROM (SELECT `post_author`, COUNT(*) AS `count` FROM {$wpdb->posts} WHERE `post_status`=’publish’ GROUP BY `post_author`) AS `stats` WHERE `count` >= {$min_posts} ORDER BY `count` DESC;”); // Do what you want to $author_ids from here on… This will … Read more

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