Ok, Point 2 should be ok !
I added following code to “s2hacks.php” in the “/wp-content/mu-plugins” folder ……
But, what is to do with Point 3 ?
function FJ_Activate_Coupon($userID, $RoleStr, $RoleB = true) { // userID is the current user redeeming the coupon, RoleStr is what you want to update, and RoleB is a boolean for updating user role or custom capability.
$user = new WP_User($userID); // create a User Object
if ($user->role[0]!=”administrator”) {
/* Modifies custom registration fields (useful when the field you want to update is present at registration)
$custom_fields = get_user_option(“s2member_custom_fields”);
$custom_fields[“coupon_id”] = $CouponID;
update_user_option($user->ID, “s2member_custom_fields”, $custom_fields);
*/
if ($RoleB === true) { //modify user role
// This can only modify 1 role or capability at a tiem. You need to run the funcion with 1 parameter.
$user->set_role($RoleStr); // subscriber, or s2member_level[1 2,3,4]
}
else { //modify custom capability
$user->add_cap(“access_s2member_ccap_”.$RoleStr ); // adds custom capability
}
$expire_on = strtotime(“+2 years”); // establish the EOT for the role
update_user_option ($user->ID, “s2member_auto_eot_time”, $expire_on);
//return “ID: “.$user->ID.” Update: “.$user->roles[0].” Bool: “.$RoleB; // Ignore: lines I used for testing
} else {
//return “No ha corrido el codigo porque eres Admin”; // Ignore: lines I used for testing
}
}