Add xprofile to user
-
the code I am created that makes the users register and auto login. My difficulty is in adding xprofile for this user. Could you help me?
add_action('quform_post_process_7','register', 10, 2); function register ($result, $form) { $username = $form->getValueText( 'quform_7_6' ); $email = $form->getValueText( 'quform_7_6' ); $password = $form->getValueText( 'quform_7_7' ); $role = 'shop_manager'; $userId = wp_insert_user(array( 'user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'role' => $role, )); $hash = wp_hash_password($password); update_user_meta( $user_id, '_is_shop_manager', 1 ); update_user_meta($userId, 'nickname', $form->getValueText('quform_7_28')); update_user_meta($userId, 'first_name', $form->getValueText('quform_7_28')); if(!is_wp_error( $userId)){ wp_set_current_user( $userId); // set the current wp user wp_set_auth_cookie( $userId); // startthe cookie for the current registered user if (bp_is_active('xprofile')) { if (!empty($usermeta['1,43,44'])) { $profile_field_ids = explode(',', $usermeta['1,43,44']); foreach ((array) $profile_field_ids as $field_id) { if (empty($usermeta["field_1"])) { $usermeta = array( 'field_1' => $form->getValueText('quform_7_28'), 'field_43' => $form->getValueText( 'quform_7_6' ), 'field_44' => $form->getValueText('quform_7_20'), ); } $current_field = $usermeta["field_1"]; xprofile_set_field_data($field_id, $user_id, $current_field); } } } } return $result; } // format cleaned up for readability
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.