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.

About: John Prusinski

Sorry, I've not written a description yet. I'll get to it soon!


Topics I'm Subscribed To


Topics I've Started

Viewing 3 topics - 1 through 3 (of 3 total)
Topic Count Last Reply
Registration questions

By:  John Prusinski in: Community Forum

voices: 3
replies: 17

4 years, 8 months ago  Raam Dev

Admin notification of profile updates

By:  John Prusinski in: Community Forum

voices: 2
replies: 1

4 years, 8 months ago  Cristián Lávaque

Profile fields that aren't part of Registrati

By:  John Prusinski in: Community Forum

voices: 2
replies: 3

4 years, 8 months ago  Cristián Lávaque

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

My Latest Replies (From Various Topics)

Viewing 13 replies - 1 through 13 (of 13 total)
Author Replies
Author Replies
Posted: Tuesday Apr 24th, 2012 at 4:38 pm #11756

Ah, thanks for that… I checked, and the admin notification was not being sent. Then I remembered that I recently changed my s2hacks.php… I took that out, and it works fine now.

Posted: Tuesday Apr 24th, 2012 at 2:47 pm #11725

First let me say I’m really appreciative of S2member’s tech support!

And… I have another follow-up on this issue:

This is the code I’m now using, which replaces the array with a routine for reading the Certification Numbers from an external text file:

<?php
$cert = get_user_field ("cert_number");
  $fh=fopen('http://ecbiz119.inmotionhosting.com/~nappit5/wp-content/uploads/2012/04/datafile.txt','r');
  $query=$cert; 
  $found=FALSE;
  while(!$found && $line=fgets($fh))
  {
    if(trim($line)==$query)
      $found=TRUE;
	$user = wp_set_current_user(S2MEMBER_CURRENT_USER_ID);
	$user->set_role('s2member_level1');
  }
  fclose($fh);
  echo "Certification {$query} was ". ($found?'':'not ') .'found';
?>

You’ll note I also replaced

$user = new WP_User(S2MEMBER_CURRENT_USER_ID);

with

$user = wp_set_current_user(S2MEMBER_CURRENT_USER_ID);

and that changes the user’s role immediately upon loading the page, instead of only after reloading. This all works great! Except for one thing: it no longer sends a notification by email when a new member registers.

Any idea why this is happening, or what I can do about it?

Thanks!

Posted: Tuesday Apr 24th, 2012 at 12:16 pm #11715

Excellent, thanks for your help!

Posted: Wednesday Apr 11th, 2012 at 1:22 pm #10573

You’re welcome! As it turns out, the code worked better if I used ‘get_user_field (“cert_number”)’ instead of get_s2member_custom_fields and then looked for the “cert_number” field.

I do have one slight glitch, however, which is that the code establishes the role correctly, but not on first load of the page. I tested this with this code:

<?php
$valid_certs = array(1,2,3,4,);
$cert = get_user_field ("cert_number");
if (isset($_GET['first']) && !empty($cert) && in_array($cert, $valid_certs)) {
	$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
	$user->set_role('s2member_level1');
}
?>

[s2If current_user_can(access_s2member_level1)]
    Hello Trainer. Your certification number is [s2Get user_field="cert_number" /]
[/s2If]

[s2If !current_user_can(access_s2member_level1)]
    I'm sorry, this area of the site is for NAPPI Certified Trainers only.  Thanks!
[/s2If]

When the page first loads, the text “I’m sorry, this area of the site is for NAPPI Certified Trainers only. Thanks!” is what appears, even if the user does have a Certification number; however, if I reload the page, the correct text, “Hello Trainer… etc.” shows up instead, leading me to believe that the role-setting code doesn’t execute immediately, before the code below it is read.

It’s not the end of the world if that’s not possible; since the user level IS properly set, I can just work around the issue. But it would be more elegant to force the role-setting code to execute immediately; is that possible?

Thanks!

Posted: Tuesday Apr 10th, 2012 at 9:20 pm #10531

Hmmm… interesting. I have it working now, and what I had to do was change

&& in_array($cfields['cert_number'], $valid_certs)

to

&& in_array('cert_number', $valid_certs)

I’m not really sure why that works better, it seems that the original example is the right syntax. But who am I to argue?
Thanks again for your help!

Posted: Tuesday Apr 10th, 2012 at 4:44 pm #10518

Wait, back to the drawing board… I removed the second two conditions, and now “First” is echoed. That means the issue is somewhere else. I’ll beat it up for awhile longer and hopefully solve it, if not I’ll be back for another round…

Thanks for your help!

Posted: Tuesday Apr 10th, 2012 at 4:37 pm #10517

But the last two conditions are demonstrably true: the cert_number field is not empty, and cert_number is one of the numbers in the array. That means the only one that’s apparently not true is the first condition, so the ‘first’ variable is not set, right?

Posted: Tuesday Apr 10th, 2012 at 2:18 pm #10484

Hi, Thanks again… it’s not getting too complicated for me, but it’s not working. I used your exact code, and everything is executing without errors, but it doesn’t seem to be successfully setting the variable “first”.

I made a new Login Welcome page, so that I can tell that the One-Time Offer is working (i.e., it sends the user to the new page only on first login, after that it sends them to the old page). The url is showing up correctly when it does that, with the variable “first” in the browser url field.

However, it’s not changing the user’s level to 1. To test that the variable was being set correctly, I added this code to the page:

<?php
$valid_certs = array(1,2,3,4,);
$cfields = get_s2member_custom_fields();
if (isset($_GET['first']) && !empty($cfields['cert_number']) && in_array($cfields['cert_number'], $valid_certs)) {
  echo "First";
} else {
  echo "Variable is NOT set";
}
?>

which invariably returns “Variable is NOT set”.

I also have:

<?php if (current_user_can("access_s2member_level1")){ ?>
    Hello Trainer.
<?php } else { ?>
    Epic fail.
<?php } ?>

[s2Get user_field="cert_number" /]

Which returns “Epic fail”, but also does show the cert_number variable correctly (I’ve tried all the numbers in the array, 1, 2, 3, and 4 at different times), which shows that the conditionals would be met in the if statement, if isset was finding the variable ‘first’.

Does that make sense? Any suggestions? Thanks!

Posted: Sunday Apr 8th, 2012 at 5:46 pm #10333

Excellent, thanks, I’m getting the idea. I appreciate your patience with a beginner! Here’s how I read the code:

The first line sets up an array for valid certification numbers, with possible values of 1, 2, 3, or 4.
The second line checks for custom fields in the registration form.
The next section says that if the custom field called cert_number is not empty, and its value is one of the numbers in the array established above (1, 2, 3, or 4), then the new user who is filling out this registration form should have his role set to level 1.

All of which is basically what I need, except I’m not sure where to put the code… does it go in one of the php pages available in the Appearance -> Editor section, or elsewhere?

Thanks again!

Posted: Sunday Apr 8th, 2012 at 2:44 pm #10323

Hi, thanks for responding so quickly. I’m still unsure of how to proceed, even on a basic level. I had already seen the doc page for S2Get custom fields, and I’ve been able to use that to, for instance, show on the Welcome page the name of the currently logged in member, the “true” or “false” for their answer to the “certified trainer?” radio button, and their Certification Number after they log in.

However, I don’t know the syntax to set up the conditional for which the “translation” would be something like “if currently-logged-in-user is a certified trainer then show this content”. Or, even less, “if the registrant’s entry in the certification number field is 560369, check this list to see if that’s a valid number, and if it is, set their member level to 1”.

The links you sent me have lots of information which I suspect would be highly useful if I had a more basic understanding of how to apply it, but I really need some initial help at a more basic level before I can make sense of it.

Thanks in advance!

Posted: Saturday Mar 31st, 2012 at 6:24 pm #9683

Thanks again for the suggestion; after talking to my client, what they’d like to do is have people identify themselves as a “certified trainer” (or not) upon registration, and enter their certification number. Then the system should basically assume they’re telling the truth and send them out a confirmation and a password, which would grant them access to their protected pages on the site. When the client gets the message that there is a new member, and that they’ve identified themselves as certified, they’ll check the number, and if it’s not accurate they’ll block the access and contact the registrant to confirm the number in person.

So what I’d like to do is have people who identify themselves as “certified” on registration be automatically upgraded to level 1 when they log back in, which I’m thinking could be done with custom capabilities, but after spending some hours trying to figure out how to do that, I’m still stuck.

I’ve added the registration fields that will identify a “certified’ user, and I’ve been able to use the [S2Get…] shortcode to display their information on the screen when they log in, but I don’t know the syntax for the shortcode (or php) to use that information to write a conditional something like “if user_field ‘certification’ = “true” then level=1″.

Can someone help me with this? Thanks!

Posted: Monday Mar 12th, 2012 at 3:59 pm #7918

Excellent, thanks. I’m brand new to S2, so I have a learning curve ahead of me, but you’ve pointed me in a couple of useful directions!

Posted: Monday Mar 12th, 2012 at 3:38 pm #7915

Hi, I didn’t ask the original question, but I’m also looking for an answer to it. In my case, my site will have free subscribers, which is basically the interested general public, but I also need a free level which is only available to people with a specific professional certification.

The latter group will fill out the registration form and include their certification number. This registration request will be reviewed by a human, who will check to see that the certification number is valid, and if so, provide the registrant with a password for the “professional” level.

Is that something that S2Member will handle, and if so, does it require the Pro version?

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

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.