Page 1 of 1

Register by buying a product

PostPosted: December 20th, 2011, 5:25 pm
by yifatcohen
Members can register to my site by purchasing a product (through a Pro form that sells them a book/service and gives them access to level 1).

I'd like my posts to send them to the product page (http://gplusdecoded.com/products-2), rather than http://gplusdecoded.com/wp-login.php?action=register

Where do I control that?

Also - how do I use a coupon that basically gives the product away for free (right now it charges $0.01) even if the coupon value is greater than the product value.

Re: Register by buying a product

PostPosted: December 20th, 2011, 9:13 pm
by Raam Dev
Hi yifatcohen,

I don't understand what you're trying to control. Can you give me an example post that sends people to the register page? What page did you select for the Membership Options Page (WP Admin -> s2Member -> General Options -> Membership Options Page)?

Normally when a non-logged in user tries to access a protected page, s2Member will redirect them to the Membership Options Page. That's the page where they can purchase access. So, it sounds like your 'products-2' page should be the one selected as the Membership Options Page.

Regarding the free coupon: You'll need to use a free registration form and hide it from anyone who doesn't have the free coupon code. Please see this example: viewtopic.php?f=4&t=16176&p=54466#p54503

Re: Register by buying a product

PostPosted: December 21st, 2011, 7:56 pm
by yifatcohen
That voucher thing isn't working for me. I get a syntax error.

Here's what I've done:
I've installed the Allow PHP in Posts and Pages plugin, and then put this in my page:

Code: Select all
[php] if (isset($_GET['?s2p-coupon='] && $_GET['?s2p-coupon='] == 'free')) { header( 'http://gplusdecoded.com/wp-login.php?action=register' ) ;[/php]

[
php] } else { [/php]
content of my paid form
[php] } [/php] 


When I go to: http://gplusdecoded.com/products-2/the- ... oupon=FREE I get:
Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ‘,’ or ‘)’ in /homepages/23/d393606834/htdocs/gplusdecoded2/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(83) : eval()’d code on line 1

Parse error: syntax error, unexpected ‘}’ in /homepages/23/d393606834/htdocs/gplusdecoded2/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(83) : eval()’d code on line 1

Re: Register by buying a product

PostPosted: December 22nd, 2011, 3:24 pm
by Raam Dev
I'm not sure how that plugin evaluates the PHP code (I've had good luck with the PHP Execution plugin), but it might have trouble separating the PHP IF block into separate [php][/php] blocks.

Can you try giving the other PHP plugin a try and see if that works?

Re: Register by buying a product

PostPosted: December 23rd, 2011, 6:03 am
by Cristián Lávaque
Yifat, you had the var name wrong in the $_GET array, and the header function was missing 'Location: ' before the URL.
http://php.net/manual/en/reserved.variables.get.php
http://www.php.net/manual/en/function.header.php

About the syntax error, it's probably a limitation with those PHP shortcodes, not sure.

Here's what I'd try, since you'll be doing a redirection instead of showing one content or another.

Create the dir/file /wp-content/mu-plugins/s2hacks.php and add this:

Code: Select all
<?php 

if 
(isset($_GET['s2p-coupon'] && $_GET['s2p-coupon'] == 'free')) { 
    header
('Location: http://gplusdecoded.com/wp-login.php?action=register');
}

?>
Don't leave any spaces or lines outside the PHP tags.

Let me know if that works. I hope it helps. :)