Hello,
I have just re launched our website and it seems the products do not get added to user.
I have made a custom process where the user registers first to the site and then after that they are auto logged in and then brought to the shopping cart page. (note I am also using AUTHORIZE.NET plugin ) After which they purchase the product. I get the email confirming there purchase but when I look in the new users profile they do not have any products purchased. I am short on time and need to get this working soon. I'll post some code up too so you can see what I am doing.
I auto log in the user here and redirect them to the shopping cart page if they are purchasing a premium subscription if not they go to the free account process
Code:if ( 'completed-confirmation' == bp_get_current_signup_step() ) { $creds = array(); $creds['user_login'] = $_POST['signup_username']; $creds['user_password'] = $_POST['signup_password']; $user = wp_signon( $creds, true ); //check if this is going to be a purchase signup if ( isset($_POST['product']) ) { if ( '1' == $_POST['productID'] ) { //this is going to be AAPLTrader Premium Product //set cookie for new paid users setNewUserPaidCookie(); wp_redirect('https://www.aapltrader.com/checkout-2?subscription=2&claim=49d393ce7e1346fa24cecd5d0eb1533d'); exit; } else { //set cookie for new users setNewUserCookie(); wp_redirect(get_bloginfo('url').'/follow'); exit; } } else { //set cookie for new users setNewUserCookie(); wp_redirect(get_bloginfo('url').'/follow'); exit; } }
Here is the code i need to use to assign a role to the user after purchasing.
They above code returns blank after getting to the Thank you page. It returns with no products for the user. As well when I go into their profile. They do not have a product purchased.Code://check if they have purchased a product and then add swing trader group and give them role global $current_user; $user_id = $current_user->ID; if (function_exists('MWX__GetListOfProductsForUser')) { $all_members_data = MWX__GetListOfProductsForUser ($user_id); } //product_id 0 = aapltrader premium access if (!empty($all_members_data) ) { if ($all_members_data[0][product_id] == "0") { //add role to this user // get user by user ID $user = new WP_User( $user_id ); if ($user->has_cap( 'create_groups' ) ) { //do nothing } else { echo "no cap"; //add the role $user->add_role( 'premium_member' ); } //add them to swing trader group if( !$user_id ) return false; groups_accept_invite( $user_id, 8); } }
This worked for my test user but who had already had an account.
Could your plugin not see the user because he just logged in? I don't think my code is causing anything wrong. Also I get the emails saying please log in with your existing account and such.
Please any help would be greatly appreciated.
Thanks!


Reply With Quote