Community Support Forums — WordPress® ( Users Helping Users ) — 2011-10-30T18:37:53-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=15715 2011-10-30T18:37:53-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50495#p50495 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
Also, for anyone working with this:

$fields is an array, and therefore cannot be echo'ed out. It must be shown using print_r.

Cheers!

Statistics: Posted by Bruce C — October 30th, 2011, 6:37 pm


]]>
2011-10-30T18:11:29-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50492#p50492 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
So a final wrapup:

1) Implement the PHP Execution plugin.
2) Create a custom registration field.
3) Create a Wordpress Page.
4) Implement the first block of code on the page:
Code:
<?php
$fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
$fields["custom_field"];
?>

5) Implement second conditional block of code on the page:
Code:
<?php
$fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
if (current_user_can('access_s2member_level0') && $fields["custom_field"] === 'field_value')
   {
   ?>
   Content for this condition goes here.
   <?php
}
else if (current_user_can('access_s2member_level0') && $fields["custom_field"] === 'another_field_value')
   {
   ?>
   Content for this other condition goes here.
   <?php
}
else
   {
   ?>
   Dump public content here, or add additional conditions.
   <?php
}
?>


Hope this helps people looking.

Statistics: Posted by stebesplace — October 30th, 2011, 6:11 pm


]]>
2011-10-30T18:07:35-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50491#p50491 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
Boom, I found the issue.

current_user_can('s2member_level0') needs to be current_user_can('access_s2member_level0')

And what would you know, it worked!!!!!!

I'm going to test some more on other fields, but I'm wicked impressed. So far so good! Thanks Ace!!!!

Statistics: Posted by stebesplace — October 30th, 2011, 6:07 pm


]]>
2011-10-30T18:06:40-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50490#p50490 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
It looks as though it's not picking up the response right.

Try changing === to ==

If that doesn't work, try changing ["gender"] to [gender]

Statistics: Posted by Bruce C — October 30th, 2011, 6:06 pm


]]>
2011-10-30T17:52:27-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50489#p50489 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
Array
(
[id] => 1
[ip] => 76.254.57.97
[reg_ip] => 99.35.230.170
[email] => user.name@gmail.com
[login] => uname
[first_name] => User
[last_name] => Name
[display_name] => User Name
[subscr_id] =>
[subscr_or_wp_id] => 1
[subscr_gateway] =>
[custom] =>
[gender] => Male
[marital_status] => Single
[student] => No
[education] => Some Highschool
[employment] => Full
[household_income] => 0-25,000
)

So it's deff able to pull in those custom fields, that's resolved. I thought perhaps it might be case sensitive, so tried gender instead of Gender, not the case.

Statistics: Posted by stebesplace — October 30th, 2011, 5:52 pm


]]>
2011-10-30T17:46:04-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50488#p50488 <![CDATA[Re: Form registration field with CCaps to determine access?]]> Statistics: Posted by Bruce C — October 30th, 2011, 5:46 pm


]]>
2011-10-30T17:43:14-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50487#p50487 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
[s2Get user_field="Gender" /]

Gave me an output of Male, on the page. So the field is working.

Made the change to current_user_can, no modification to the output. Still shows the final else condition.

I'm wondering if S2MEMBER_CURRENT_USER_FIELDS is returning the correct results for my custom fields? See this thread (albeit back in 2010 and apparently resolved) viewtopic.php?f=4&t=378 to see what I am talking about.

Also, if I echo $fields, I get nothing: echo $fields["Gender"];

Regardless, still trying to get this working, but I think it's really close!

Statistics: Posted by stebesplace — October 30th, 2011, 5:43 pm


]]>
2011-10-30T17:35:23-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50486#p50486 <![CDATA[Re: Form registration field with CCaps to determine access?]]> Statistics: Posted by stebesplace — October 30th, 2011, 5:35 pm


]]>
2011-10-30T17:32:15-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50485#p50485 <![CDATA[Re: Form registration field with CCaps to determine access?]]> Statistics: Posted by Bruce C — October 30th, 2011, 5:32 pm


]]>
2011-10-30T17:26:09-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50483#p50483 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
Code:
<?php
$fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
if (current_user_is('s2member_level0') && $fields["Gender"] === 'female')
   {
   ?>
   Things for females
   <?php
}
else if (current_user_is('s2member_level0') && $fields["Gender"] === 'male')
   {
   ?>
   Things for males
   <?php
}
else
   {
   ?>
   Things for non-members
   <?php
}
?>


Placed that code on my page, specifically enabling the execute php plugin as well, and my output seems to be the "Things for non-members, though my current logged in user is an admin (me) and I have set the gender to be male. Also placed the first block of code on the page above the second block too.

So i have a custom registration field in S2 called "Gender" exactly as spelled there (Gender is a unique_id), setup as a radio button. The user has Male checked (one of the options).

Looking into this more, but that's where I'm at so far.

Statistics: Posted by stebesplace — October 30th, 2011, 5:26 pm


]]>
2011-10-30T17:14:20-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50482#p50482 <![CDATA[Re: Form registration field with CCaps to determine access?]]> Statistics: Posted by Bruce C — October 30th, 2011, 5:14 pm


]]>
2011-10-30T17:10:41-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50480#p50480 <![CDATA[Re: Form registration field with CCaps to determine access?]]> Statistics: Posted by stebesplace — October 30th, 2011, 5:10 pm


]]>
2011-10-30T17:06:25-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50478#p50478 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
You're going to need a PHP Execution Plugin Installed.

In order to get a custom value without using the [s2Get] shortcode, you're going to have to get the database array, and JSON decode it:

Code:
<?php
//This gets the user fields
$fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
//Then, use the $fields variable to get your data.
$fields["my_unique_field_id"];//Replace this with yours.
?>


To see if it equals what you want, you'll need to do this sort of thing:

Code:
<?php
$fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
if (current_user_is('s2member_level0') && $fields["user_gender"] === 'female')
{?>
Things for females
<?php}else if (current_user_is('s2member_level0') && $fields["user_gender"] === 'male'){?>
Things for males
<?php}else{?>
Things for non-members
<?php}?>


If this isn't what you're looking for, let me know.

Statistics: Posted by Bruce C — October 30th, 2011, 5:06 pm


]]>
2011-10-30T16:52:00-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50477#p50477 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
Otherwise, one would have to implement a group setup using another 3rd party tool to clump people together. The problem with that approach, is that it would need some level of customization to automatically put people based on identifiers into groups, or manually adding users in. But I think what I described above should work in theory keeping the system pretty clean.

Thanks Ace!

Statistics: Posted by stebesplace — October 30th, 2011, 4:52 pm


]]>
2011-10-30T16:29:17-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50475#p50475 <![CDATA[Re: Form registration field with CCaps to determine access?]]> Statistics: Posted by Bruce C — October 30th, 2011, 4:29 pm


]]>
2011-10-30T16:19:43-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50473#p50473 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
So a hypothetical setup could be, as shortcodes on that specific page that I'm requiring only "female" to be able to view:

Code:
[s2If current_user_is(s2member_level0) AND (what conditional statement would go here in order to validate that the registration field entered was female?)]

Content for logged in user who is female goes here

[/s2If]


Thanks!

Statistics: Posted by stebesplace — October 30th, 2011, 4:19 pm


]]>
2011-10-30T16:05:40-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50465#p50465 <![CDATA[Re: Form registration field with CCaps to determine access?]]>
The custom registration forms are not the same thing as custom capabilities. In order to get custom registration forms, you will need to use s2Get. You can find what you are looking for under Dashboard->s2Member->API/Scripting->Simple/Shortcode Conditionals In example 4.

You will have to run a check to see if it equals male or female.

Cheers!

Statistics: Posted by Bruce C — October 30th, 2011, 4:05 pm


]]>
2011-10-30T15:50:37-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15715&p=50457#p50457 <![CDATA[Form registration field with CCaps to determine access?]]>
I have a custom membership configuration which requires users with lvl #0 (subscriber) to be logged in to view a specific page. The page contains a form that they fill out as a "task", so to speak. The page, is only visible to people logged in. So far so good.

I've added a few custom entries to the registration form, some of which include Gender, State, Country, etc.

What I can't figure out, is the relationship between a registration field, such as Gender, and my ability to use CCaps as a way to restrict people within a certain gender, to view a specific page. So if a user is Male, they can get access to a page to fill out a form and complete their task.

The bigger goal here, is the ability to restrict specific pages for registration values such as geographic location. That allows me to subset users in a region such as San Francisco, that can view one page, versus people in New York City, who would view another. Make sense?

Hopefully I was able to get the concept across here, and I think CCaps is the method to use, since all users are only a lvl #0. I'll keep searching, but if anyone has any ideas, let me know. Thanks :)

Statistics: Posted by stebesplace — October 30th, 2011, 3:50 pm


]]>