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.

Free subscription coupon

Home Forums Community Forum Free subscription coupon

This topic contains 7 replies, has 3 voices. Last updated by  Eduan 4 years, 9 months ago.

Topic Author Topic
Posted: Thursday Mar 15th, 2012 at 7:56 am #8215
Nigel
Username: enquirer32

Read the how-to but this is just a page which anyone can access and sign up for free – how can one provide a page which requires people to input a coupon reference? THX.

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Thursday Mar 15th, 2012 at 11:07 am #8249
Raam Dev
Username: Raam
Staff Member

Hi Nigel,

While s2Member doesn’t currently support “free registration coupons”, it’s possible to create your own solution by having the visitor include the voucher/coupon code in the URL. Please see this thread on the old forum for more information: http://www.primothemes.com/forums/viewtopic.php?f=4&t=16176&p=54466#p54503

You could also use this method to create a page that includes a form with a text field for the coupon code and upon submission checks the coupon code and then proceeds to the free registration form if the code was correct.

Posted: Thursday Mar 15th, 2012 at 1:16 pm #8268
Nigel
Username: enquirer32

Tried this but doesn’t seem to work with my permalink structure. Could you possible given an example, I am sure it would be very useful for everyone. Thx.

Posted: Friday Mar 16th, 2012 at 1:31 pm #8379
Raam Dev
Username: Raam
Staff Member

Hi Nigel,

You’ll need to install a plugin like Exec-PHP to run PHP code inside WordPress page. Then you’ll use code like the following to detect if the page is being called with ?voucher=free at the end of the URL:

<?php if (isset($_GET&#91;'voucher'&#93;) && $_GET&#91;'voucher'&#93; == 'free') { ?>
Show the free registration form.
<?php } else { ?>
Show the payment form.
<?php } ?>

The other option would be to create a page specifically for submitting the voucher code. You might use a form like this on the ‘Submit Voucher’ page:

<form id="voucherForm" method="post" action="/checkout/">
<input name="voucher" type="text" maxlength="255" value=""/> 
<input id="saveForm" type="submit" name="submit" value="Submit" />
</form>

Then on the /checkout/ page, you’d use PHP like the following to check if the voucher code was valid:

<?php if (isset($_POST&#91;'voucher'&#93;) && $_POST&#91;'voucher'&#93; == 'free') { ?>
Show the free registration form.
<?php } else { ?>
Show the payment form.
<?php } ?>
Posted: Saturday Mar 17th, 2012 at 10:33 am #8449
Nigel
Username: enquirer32

Thx but I just can’t ever seem to get the page to deflect either in option 1 or 2. Certainly I find option 2 a little more elegant but when they submit the form they just end up at the free registration page with no divert. This is what I have in my posts –

voucher code = free
url to free registration =

http://mydomain.com/freeregistration

url to paid registration =

http://mydomain.com/paidregistration

Form to submit voucher:

<form id="voucherForm" method="post" action="http://mydomain.com/freeregistration">
<input name="voucher" type="text" maxlength="255" value=""/> 
<input id="saveForm" type="submit" name="submit" value="Submit" />
</form>

This then passes to a page (mydomain.com/freeregistration) where I have the following:

<?php if (isset($_POST['voucher']) && $_POST['voucher'] == 'free') { 
// stay here 
 } else { 
 header("Location:http://mydomain.com/paidregistration"); 
 } ?>
Posted: Monday Mar 19th, 2012 at 12:48 pm #8544
Raam Dev
Username: Raam
Staff Member

Hi Nigel,

You cannot use header(“Location:”) that way to redirect the page. You need to set up your pages the way my example describes.

Unfortunately this is getting into the realm of custom programming, which is outside the scope of our Support Policy. If you have further questions about how redirections and such work, you may wish to post a thread on the WordPress Support Forum.

Posted: Tuesday Mar 20th, 2012 at 4:29 am #8587
Nigel
Username: enquirer32

Ok, I have finally understood, and… it works! Thank you! I hadn’t wrapped my pages into the php code above and I needed to set up the forwarding url to include the voucher so the url on the coupon page need to read

urlmydomain.com/subscriptionpage/?voucher=free

Then when it hit the subscription page it read the voucher in the url and bingo passed it to the free sign-up. I was over-complicating matters. Thanks again.

Posted: Tuesday Mar 20th, 2012 at 9:25 am #8602
Eduan
Username: Eduan
Moderator

Hello Nigel, thanks for the follow-up.

I’m glad you were able to solve your problem. :)

Also, thanks for reporting back, really appreciate it. :)

Viewing 7 replies - 1 through 7 (of 7 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.