PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

level 1 access via email activation link

s2Member Plugin. A Membership plugin for WordPress®.

level 1 access via email activation link

Postby antseo » September 11th, 2011, 9:38 pm

I like the idea of allowing users to sign up using the registration form which then gives them a level 0 access.

What I need to know if it's possible to send them an activation link via the email they used to sign up with . Then after clicking on that link, it sends them back to the site where it automatically gives them level 1 access. Is that possible with s2member free version?
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 12th, 2011, 7:37 pm

This is possible, the e-mail would need to be set up via Dashboard -> s2Member -> General Options -> Email Configuration. This could perhaps be set up through a private Post, however it would take some custom coding to get configured correctly.

Hope that helps a bit!
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 12th, 2011, 8:58 pm

so an email activation cannot trigger moving from level 0 to level 1?
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 12th, 2011, 9:08 pm

Not directly, it would need to direct a member to an activation page, which would then upgrade them to level 1.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 12th, 2011, 9:20 pm

so is there an activation page or script built into s2member or s2member pro that can do this?

I guess I could set it up so all pages are accessed if a user is logged in. which of course would mean they registered and successfully logged in.

Okay, how about we disregard the email validation then. is there no other way to make it so that open enrollment can be bumped up to level 1 access upon a successful registration?
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 13th, 2011, 10:31 am

The email validation is possible. I found the code for bumping a member to level 1:

Code: Select all
$user = new WP_User(wp_get_current_user()->ID);
    $user->set_role("s2member_level1");


You could wrap this in conditionals (Dashboard -> s2Member -> API/Scripting -> Simple Shortcode/Conditionals) to see if the user is logged in, and if they are already level 1.
This would be in a post or page of your liking that is private.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 13th, 2011, 10:59 am

okay, that's great. I'll see if I can get that to work.
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby antseo » September 13th, 2011, 5:42 pm

Okay, now I've screwed myself :(

I added this bit of code onto a page:

[s2If is_user_logged_in()]
$user = new WP_User(wp_get_current_user()->ID);
$user->set_role("s2member_level1");
[/s2If]

I logged in as admin and it changed my role from admin to level 1! What do I change now to get my admin role back?
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 13th, 2011, 9:02 pm

Well at least we know it works! ( :lol: )

This page can help you do that.
http://www.dnawebagency.com/how-to-add- ... s-database

Try using the current_user_is('s2member_level0') function instead.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 13th, 2011, 11:13 pm

Okay, so I have this:

[s2If is_user_logged_in() AND current_user_is(s2member_level0)]
<?php $user = new WP_User(wp_get_current_user()->ID);
$user->set_role("s2member_level1"); ?>
[/s2If]

If I'm logged in as admin, I shouldn't be affected, right? Only users who log in who have level0 access will be bumped up to level1 access. Does that code look correct then?
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 13th, 2011, 11:16 pm

Try just
[s2If current_user_is(s2member_level0)]

then there is no chance of you having to go through that again.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 13th, 2011, 11:24 pm

Okay, I just tried that but it keeps changing my admin role to level 1. Why would it be doing that. Is it because admin encompasses all roles?

Is there a code for is not administrator?
Last edited by antseo on September 13th, 2011, 11:27 pm, edited 1 time in total.
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 13th, 2011, 11:27 pm

Hi again seozones,

This is mostly for those not as experienced with s2Member, or with PHP/HTML, therefore not directed at seozones himself, but those who may be interested in this for their own sites.

Here's a simple, easy way to get this working on your site.

There are 2 things that need to be set up in order to get this to work, the e-mail, and the page.

In order to get the e-mail set up, you first need to enable custom e-mail settings via Dashboard -> s2Member -> General Options -> Email Configuration

1.png



This is an example code that needs to be added to the e-mail.

(EDIT: in order to get this to work, follow the instructions in viewtopic.php?f=4&t=15226 to change the form to accept HTML)

Code: Select all
<form action="http://example.com/my-custom-page" method="post" name="regId">
<input type="hidden" name="id" value="%%user_id%%"/>
</form>
<a href="#" onClick="document.regId.submit();return false">To finish the registration process, click here.</a>


This creates a link that cannot be replicated, and only works if used through the e-mail.

Then, the action="" part of the code should be customized to the page that is being used.

The page should contain this code, which can be customized to how you like it. Really, any page could be used, as long as the conditionals block the normal output.


This is the code that will bump the user to level 1.
Code: Select all
<?php
if (!empty($_POST['id']))
{
$user = new WP_User($_POST['id']);
$user->set_role("s2member_level1");
}
else
{
//Regular content
}
?>


And that does it. If the user got the e-mail, they should click on the link, it checks to see if the id is posted, then, if it is, it bumps the user who clicked the e-mail's account to s2Member Level 1 whether they are logged in or not.

Cheers!
Last edited by Bruce C on September 21st, 2011, 8:22 pm, edited 2 times in total.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 13th, 2011, 11:28 pm

@seozones

Could it have something to do with an else function not being placed?
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 13th, 2011, 11:52 pm

Okay, thanks for that but I added that html into the custom email area and inside the email was the html. Do I need to wrap php code around all of that?

Just to test it out, I tried it in the url using... http://www.domain.com/email-validate?id=43

But the level did not change from level0 to level1.
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 14th, 2011, 12:29 am

The code for the e-mail is HTML, so you don't need PHP for it.

What might be causing that is that you're using the $_GET method for it. If you want to do it like that, try using the $_REQUEST['']; function instead, which can be used for both post and get methods.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 14th, 2011, 6:44 am

I'd like to try to use your method and add in that html into that custom email field. Why wouldn't it recognize html code?
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 14th, 2011, 11:23 pm

try the edited code from my earlier post, replacing $_POST with $_REQUEST... then if you're going to use the ?id=43, it should work.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 15th, 2011, 9:53 am

okay great. That worked, at least from the url. If I wanted to do that from a form though, I've placed the html into the new user email configuration but the email output is raw html code. Any suggestions on getting to work? does the new user email configuration recognize html code?
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 15th, 2011, 10:59 pm

Ah, yes. It looks as though you can't put forms into e-mails. Instead, use the $_GET method. Just use the replacement code %%user_id%% like this:

http://example.com/my-page?id=%%user_id%%
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 16th, 2011, 10:33 am

ok cool. Thanks Ace!
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby antseo » September 16th, 2011, 5:48 pm

Hi Ace. For some reason, that code above will not work now like it did a few days ago ...

<?php
if (!empty($_REQUEST['id']))
{
$user = new WP_User($_REQUEST['id']);
$user->set_role("s2member_level1");
}
else
{
//Regular content
}
?>

I'm just trying to hit that page via the url such as http://www.domain.com/page?id=50

But the user does not upgrade from level 0 to level 1 now.

Did any recent upgrade to s2member prevent that code from working. I have php execution installed and can run php on a page (tested in using hello world script).
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby antseo » September 16th, 2011, 6:52 pm

hi again Ace. The problem with the above code is that what if someone finds out what the id is for Admin then changes his role.

So only members who have level 0 privilege (they've signed which means they can log in) and who do not have admin role will be upgraded. Based on that logic, what can be changed on the following to make it so that if an admin hits that script on a page, he does not downgrade his role?

This does not seem to work:

[s2If current_user_is_not(administrator)]
[s2If current_user_is(s2member_level0)]
<?php $user = new WP_User(wp_get_current_user()->ID);
$user->set_role("s2member_level1"); ?>
[/s2If]
[/s2If]
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Re: level 1 access via email activation link

Postby Bruce C » September 21st, 2011, 7:56 pm

~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: level 1 access via email activation link

Postby antseo » September 21st, 2011, 8:15 pm

nice! Thanks Ace!
User avatar
antseo
Experienced User
Experienced User
 
Posts: 127
Joined: September 2, 2011

Next

Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest

cron