unwanted user_meta data when creating new user?
-
Trying to create new user if not exists from e-commerce plugin checkout page.
Prior to submitting cart form data to PayPal, an ajax call is made passing cart form data to checkout.php which updates the db_cart, but also checks for existing user, the idea being — to verify existing user, or create new — and log in before submitting the order to PayPal. But for some reason which I cannot begin to fathom, when creating new users, wp adds ALL cart data to the new user_meta no matter what approach I take to creating the user.
Here is the ajax Post cart dataArray ( [cmd] => _cart [upload] => 1 [currency_code] => USD [business] => [email protected] [address_override] => 1 [cpp_header_image] => URL [cpp__headerback_color] => 4733AB [cpp_payflow_color] => 4733AB [cancel_return] => URL [return] => URL/my-orders?thank_you&cart_id=ADMINbLujO_CART4ea1b8f80a939 [cbt] => Return to Demo Z [item_name] => ADMINbLujO_CART4ea1b8f80a939 [amount] => 48.87 [handling_cart] => 4.97 [email] => [email protected] [user_pass] => testpass [first_name] => Suzie [last_name] => Queue [address1] => 2415 Lamar St [address2] => [city] => Edgewater [state] => CO [zip] => 80214 [country] => US [item_number_1] => ADMINbLujO_4e8f31f565a70 [item_name_1] => Wonder Widget [quantity_1] => 1 [amount_1] => 43.90 [buyer_first] => Joe [buyer_last] => Blow [user_cnfm] => [ship_to_self] => )
and here is the code from **checkout.php**
<pre> foreach ($_POST as $key => $val) $$key = $val; if(!is_user_logged_in()) { if($userID = email_exists($email)) { $user_info = $user_info = get_userdata($userID); $user_login = $user_info->user_login; $display_name = $user_info->display_name; $welcome = "Welcome Back $display_name!"; } if(@$welcome) { if(!$user_cnfm) die($welcome); $auth = get_object_vars(wp_authenticate($user_login, $user_pass)); if(array_key_exists('errors',$auth)) die("Password Error"); wp_set_auth_cookie( $userID, true); wp_set_current_user($userID, $user_login); } else { $buyer_name = "$buyer_first $buyer_last"; $ship_to_name = "$first_name $last_name"; $buyer_region = $buyer_city = $buyer_country = $buyer_ctry_code =""; if($ship_to_name != $buyer_name) { if(@$_SESSION['visitor'] || set_visitor() == true) { foreach($_SESSION['visitor'] as $key =>$val) { $new_key = "buyer_$key"; $$new_key = $val; } } } $userdata = array( 'user_login' => $email, 'user_email'=> $email, 'user_pass'=>$user_pass, 'first_name'=>$buyer_first, 'last_name'=>$buyer_last, 'display_name' =>$buyer_name, 'region' => $buyer_region, 'city' => $buyer_city, 'country' => $buyer_country, 'ctry_code' => $buyer_ctry_code ); $foo = print_r($userdata,1); $userID = insert_user($userdata); // $userID = insert_user($userdata); // $userID = wp_create_user( $email, $user_pass, $email ); // $userID = regNewUser($userdata); die("New User ID $userID"); wp_set_auth_cookie( $userID, true); wp_set_current_user($userID, $email); } } if(is_user_logged_in()) die("User is now Logged In"); else die("Error"); ?> </pre>
- The topic ‘unwanted user_meta data when creating new user?’ is closed to new replies.