<?php add_action("user_register", "my_function", 1000); ?>
Statistics: Posted by Jason Caldwell — September 27th, 2011, 1:33 pm
Statistics: Posted by Cristián Lávaque — September 24th, 2011, 10:37 pm
add_action('ws_plugin__s2member_during_configure_user_registration_front_side_free', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
if (!is_admin() && $vars['processed'] === 'yes') {
wp_new_user_notification($vars['user_id'], $vars['pass']);
wp_set_auth_cookie($vars['user_id'], false, is_ssl());
wp_redirect('http://domain.com/download-' . $vars['__refs']['level']);
exit();
}
}
require('wp-blog-header.php');
$xml = simplexml_load_file("xml.xml");
$orderID = $xml->orderID;
$role = getProductID($xml->lineItems->item->product->productID);
$firstName = $xml->paymentInfos->paymentInfo->customerFirstName;
$lastName = $xml->paymentInfos->paymentInfo->customerLastName;
$email = $xml->paymentInfos->paymentInfo->customerEmail;
$fullName = $firstName . " " . $lastName;
$autoEOT = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")+1);
if(!email_exists($email)) {
$random_password = wp_generate_password(8, false);
$generatedID = wp_create_user($email, $random_password, $email);
if ($role == "s2member_level1") {
wp_update_user( array ('ID' => $generatedID,
'first_name' => $firstName,
'last_name' => $lastName,
'user_email' => $email,
'user_login' => $email,
'user_nicename' => $email,
'display_name' => $fullName,
'user_registered' => date('Y-m-d H:i:s'),
'role' => $role
) ) ;
update_user_meta($generatedID, 'wp_s2member_auto_eot_time', date("U", $autoEOT));
update_user_meta($generatedID, 'wp_s2member_custom', 'domain.com');
update_user_meta($generatedID, 'wp_s2member_subscr_id', (int)$orderID);
} else {
wp_update_user( array ('ID' => $generatedID,
'first_name' => $firstName,
'last_name' => $lastName,
'user_email' => $email,
'user_login' => $email,
'user_nicename' => $email,
'display_name' => $fullName,
'user_registered' => date('Y-m-d H:i:s'),
'role' => $role
) ) ;
update_user_meta($generatedID, 'wp_s2member_custom', 'domain.com');
update_user_meta($generatedID, 'wp_s2member_subscr_id', (int)$orderID);
}
wp_new_user_notification($generatedID, $random_password);
} else {
if ($role == "s2member_level1") {
$currentID = email_exists($email);
wp_update_user( array ('ID' => $currentID,
'first_name' => $firstName,
'last_name' => $lastName,
'user_email' => $email,
'user_login' => $email,
'user_nicename' => $email,
'display_name' => $fullName,
'role' => $role
) ) ;
update_user_meta($currentID, 'wp_s2member_auto_eot_time', date("U", $autoEOT));
update_user_meta($currentID, 'wp_s2member_subscr_id', (int)$orderID);
} else {
$currentID = email_exists($email);
wp_update_user( array ('ID' => $currentID,
'first_name' => $firstName,
'last_name' => $lastName,
'user_email' => $email,
'user_login' => $email,
'user_nicename' => $email,
'display_name' => $fullName,
'role' => $role
) ) ;
update_user_meta($currentID, 'wp_s2member_subscr_id', (int)$orderID);
delete_user_meta($currentID, 'wp_s2member_auto_eot_time');
}
}
function getProductID($id) {
if ($id == "235875900") {
return "s2member_level1";
}
if ($id == "235876000") {
return "s2member_level2";
}
if ($id == "235876100") {
return "s2member_level3";
}
if ($id == "235876200") {
return "s2member_level4";
}
if ($id == "235876300") {
return "s2member_level5";
}
}
Statistics: Posted by seofeed — September 16th, 2011, 8:40 am