Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $webhook_posted_json = file_get_contents('php://input');
- $location_info = json_decode($webhook_posted_json, true);
- $the_user_id = 0;
- // Check if user exist or not!
- if ( !function_exists( 'get_user_by' ) ) {
- require_once ABSPATH . WPINC . '/pluggable.php';
- }
- if ( username_exists( $location_name ) ){
- $the_user = get_user_by('login', $location_name);
- $the_user_id = $the_user->ID;
- }
- else{
- $the_user_id = 0;
- }
- if ( !function_exists( 'wp_insert_user' ) ) {
- require_once ABSPATH . WPINC . '/user.php';
- }
- $password = wp_generate_password();
- // An array, object, or WP_User object of user data arguments.
- $userdata = array(
- 'ID' => $the_user_id,
- 'user_pass' => $password,
- 'user_login' => $location_name,
- 'user_email' => $location_email,
- 'role' => 'editor'
- );
- // NOTICE! Understand what this does before running.
- $result = wp_insert_user($userdata);
Add Comment
Please, Sign In to add comment