latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

limited Coupon-Codes for use xTimes only ….

Home Forums Community Forum limited Coupon-Codes for use xTimes only ….

This topic contains 3 replies, has 2 voices. Last updated by  Enrico Kabas 3 years, 1 month ago.

Topic Author Topic
Posted: Tuesday Nov 26th, 2013 at 1:35 pm #61390
Enrico Kabas
Username: Enrico

Hi !

I found a solution for this:
http://www.s2member.com/forums/topic/gift-coupon-codes-for-s2member/

but I need assistance to do this.

1.) Database entry “finished”
2.) Add a Function to your WP site …… ????
3.) Create a Form page that receives the coupon, …… ????

Is there anybody how finished this ?

Thanks,
Enrico

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Sunday Dec 1st, 2013 at 5:31 am #61545
Enrico Kabas
Username: Enrico

Hello !

No ideas ?

Posted: Monday Dec 2nd, 2013 at 10:57 pm #61581
cassel
Username: cassel

I was not even aware it was possible to have a coupon used for a limited number of times. I guess maybe with coding, it can be done. Way too advanced for me. I’ll keep an eye on this though.

Posted: Sunday Dec 8th, 2013 at 5:03 pm #61767
Enrico Kabas
Username: Enrico

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
}
}

Viewing 3 replies - 1 through 3 (of 3 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.