How to check that if current user (ID) has posts or not

Notice that your redirection must happen before the HTTP headers are sent out. You can try the following, where we place our logic inside the template_redirect hook callback (PHP 5.4+): /** * Redirect logged-in users to the admin dashboard * if the have written ‘student_form’ posts * else display [wpuf_form id=”414″] */ add_action( ‘template_redirect’, function() … Read more

wp_insert_user is not working for me?

The problem is from wp_insert_user and the fact that your value for user_pass is empty. You should update your code as so $random_password = wp_generate_password(8,false); $user_data = array( ‘user_login’ => $first_name, ‘user_pass’ => $random_password, ‘user_email’ => $trainer_email, ‘first_name’ => $first_name, ‘last_name’ => $last_name, ‘role’ => ‘trainer’ ); And remove this line wp_set_password($random_password, $user_id); You should … Read more

Total number of authors with more than one post

I believe that wp_list_authors will do what you want, sort of. You could run the function with the echo parameter false and count the results. $authors = wp_list_authors( array( ‘echo’=>false, ‘html’=>false ) ); echo var_dump($authors); echo count (explode(‘,’,$authors)); Or, alternately, and perhaps less profligately, steal that function’s SQL. $authors = $wpdb->get_results( “SELECT DISTINCT post_author, COUNT(ID) … Read more

Get all commenters on a post

I’m a little unclear as to exactly the final data you’re looking for. You said “array form”, but that’s not specific enough. So based on your code snippet, this code will provide you an array of all unique commenter user IDs. The code is essentially the same as yours, but I’ve combined a few parts … Read more

How to migrate wordpress users from one blog to another

Normally BackupBuddy should transfer users just fine, it might be issue with importing into multisite installation. Have you tried asking developers about it? As for more hands-on approach I’d try creating users in network and then overwrite hashes of their passwords in database with values from original installation.