wp_create_user hook

There are actually two actions: One when the profile is updated and one when the user is registered. # Fires immediately after an existing user is updated. do_action( ‘profile_update’, $user_id, $old_user_data ); # Fires immediately after a new user is registered. do_action( ‘user_register’, $user_id ); So as long as the user login is not empty … Read more

Best way to create a user programatically

You should read the codex page re wp_create_user. You don’t describe the context in which your code runs. You shouldn’t need all those require_once calls. Anyhow, in this line wp_new_user_notification ( testuser8,null,’both’ ); what is testuser8 ? It’s not a variable, it’s not a string, it’s just some text that probably throws an error. Try: … Read more

Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects

There was an associated post to this one that shed light on this answer. When registering the post type, I was not setting enough fields in the ‘supports’ array of the register_post_type. Adding author, whatdayaknow, gives me the data I’m looking for. Thanks to @milo for being on the right path! register_post_type(self::POST_TYPE, array( ‘labels’ => … Read more

wp_insert_user – how to send verification email before logging in

1. Insert user data into wp_users table. Create a page called “Activation” or similar to it and get the ID of that page. An activation email will be sent with the activation link to the user. function new_user($data) { // Separate Data $default_newuser = array( ‘user_pass’ => wp_hash_password( $data[‘user_pass’]), ‘user_login’ => $data[‘user_login’], ‘user_email’ => $data[‘user_email’], … Read more

What’s the difference between wp_insert_user() and wp_create_user()

None. The whole source of wp_create_user() is: function wp_create_user($username, $password, $email=””) { $user_login = esc_sql( $username ); $user_email = esc_sql( $email ); $user_pass = $password; $userdata = compact(‘user_login’, ‘user_email’, ‘user_pass’); return wp_insert_user($userdata); } It just calls insert version almost immediately, basically a shorthand wrapper. As for why it exists – core works in mysterious ways … Read more