Community Support Forums — WordPress® ( Users Helping Users ) — 2011-12-20T09:44:14-05:00 http://www.primothemes.com/forums/feed.php?f=40&t=12453 2011-12-20T09:44:14-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=57110#p57110 <![CDATA[s2Member v111220 / Package s2Member\API_Fu...]]>
s2Member v111220
Package s2Member\API_Functions ( Functions )
Docs updated: December 20, 2011, 9:44 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — December 20th, 2011, 9:44 am


]]>
2011-12-07T00:56:50-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=54792#p54792 <![CDATA[s2Member v111206 / Package s2Member\API_Fu...]]>
s2Member v111206
Package s2Member\API_Functions ( Functions )
Docs updated: December 7, 2011, 12:56 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — December 7th, 2011, 12:56 am


]]>
2011-11-05T19:20:22-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=51167#p51167 <![CDATA[s2Member v111105 / Package s2Member\API_Fu...]]>
s2Member v111105
Package s2Member\API_Functions ( Functions )
Docs updated: November 5, 2011, 8:20 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — November 5th, 2011, 7:20 pm


]]>
2011-10-29T19:04:08-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=49251#p49251 <![CDATA[s2Member v111029 / Package s2Member\API_Fu...]]>
s2Member v111029
Package s2Member\API_Functions ( Functions )
Docs updated: October 29, 2011, 8:04 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 29th, 2011, 7:04 pm


]]>
2011-10-17T15:31:36-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=47052#p47052 <![CDATA[s2Member v111017 / Package s2Member\API_Fu...]]>
s2Member v111017
Package s2Member\API_Functions ( Functions )
Docs updated: October 17, 2011, 1:31 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 17th, 2011, 3:31 pm


]]>
2011-10-11T14:14:31-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=45445#p45445 <![CDATA[s2Member v111011 / Package s2Member\API_Fu...]]>
s2Member v111011
Package s2Member\API_Functions ( Functions )
Docs updated: October 11, 2011, 12:14 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 11th, 2011, 2:14 pm


]]>
2011-10-03T15:30:17-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=43577#p43577 <![CDATA[s2Member v111003 / Package s2Member\API_Fu...]]>
s2Member v111003
Package s2Member\API_Functions ( Functions )
Docs updated: October 3, 2011, 1:30 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 3rd, 2011, 3:30 pm


]]>
2011-10-03T03:32:57-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=42290#p42290 <![CDATA[s2Member v111002 / Package s2Member\API_Fu...]]>
s2Member v111002
Package s2Member\API_Functions ( Functions )
Docs updated: October 3, 2011, 1:32 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 3rd, 2011, 3:32 am


]]>
2011-09-27T05:04:28-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=40534#p40534 <![CDATA[s2Member v110927 / Package s2Member\API_Fu...]]>
s2Member v110927
Package s2Member\API_Functions ( Functions )
Docs updated: September 27, 2011, 3:04 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 27th, 2011, 5:04 am


]]>
2011-09-26T20:56:50-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=39292#p39292 <![CDATA[s2Member v110926 / Package s2Member\API_Fu...]]>
s2Member v110926
Package s2Member\API_Functions ( Functions )
Docs updated: September 26, 2011, 6:57 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 26th, 2011, 8:56 pm


]]>
2011-09-17T16:12:02-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=37443#p37443 <![CDATA[s2Member v110915 / Package s2Member\API_Fu...]]>
s2Member v110915
Package s2Member\API_Functions ( Functions )
Docs updated: September 17, 2011, 2:12 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 17th, 2011, 4:12 pm


]]>
2011-09-14T01:12:16-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=36021#p36021 <![CDATA[s2Member v110913 / Package s2Member\API_Fu...]]>
s2Member v110913
Package s2Member\API_Functions ( Functions )
Docs updated: September 13, 2011, 11:12 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 14th, 2011, 1:12 am


]]>
2011-09-13T11:57:29-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=34752#p34752 <![CDATA[s2Member v110912 / Package s2Member\API_Fu...]]>
s2Member v110912
Package s2Member\API_Functions ( Functions )
Docs updated: September 13, 2011, 9:57 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 13th, 2011, 11:57 am


]]>
2011-08-15T13:27:39-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=30866#p30866 <![CDATA[s2Member v110815 / Package s2Member\API_Fu...]]>
s2Member v110815
Package s2Member\API_Functions ( Functions )
Docs updated: August 15, 2011, 2:27 pm

Open for public discussion.
(!-- s-words :: --)Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Summary Functions Hooks/Filters Function Summary | Function Detail Package s2Member\API_Functions ( 32 Functions ) ( 32 Functions )Function Summary public str S2MEMBER_VALUE_FOR_PP_INV() Can be used to auto-fill the invoice for PayPal® Button Codes, with a unique Code~IP combination. public null attach_s2member_query_filters() Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. public bool current_user_cannot(str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role. public bool current_user_cannot_for_blog(int|str $blog_id, str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network. public bool current_user_is(str $role) Conditional to determine if the current User is/has a specific Role. public bool current_user_is_for_blog(int|str $blog_id, str $role) Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network. public bool current_user_is_not(str $role) Conditional to determine if the current User is/does NOT have a specific Role. public bool current_user_is_not_for_blog(int|str $blog_id, str $role) Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network. public null detach_s2member_query_filters() Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. public mixed get_user_field(str $field_id, int $user_id) A powerful function that can retrieve almost anything you need to know about the current User, and/or a particular User. public bool is_category_permitted_by_s2member(int $cat_id) Conditional to determine if a specific Category is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_category_protected_by_s2member(int $cat_id, bool $check_user) Conditional to determine if a specific Category is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_page_permitted_by_s2member(int $page_id) Conditional to determine if a specific Page is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_page_protected_by_s2member(int $page_id, bool $check_user) Conditional to determine if a specific Page is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_permitted_by_s2member(int|str $what, str $type) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public bool is_post_permitted_by_s2member(int $post_id) Conditional to determine if a specific Post or Custom Post Type is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_post_protected_by_s2member(int $post_id, bool $check_user) Conditional to determine if a specific Post ( or Custom Post Type ) is protected by s2Member; without considering the current User's Role/Capabilites. public array|bool is_protected_by_s2member(int|str $what, str $type, bool $check_user) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_tag_permitted_by_s2member(int|str $tag_id_slug_or_name) Conditional to determine if a specific Tag is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_tag_protected_by_s2member(int|str $tag_id_slug_or_name, bool $check_user) Conditional to determine if a specific Tag is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_uri_permitted_by_s2member(str $uri_or_full_url) Conditional to determine if a specific URI or URL is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_uri_protected_by_s2member(str $uri_or_full_url, bool $check_user) Conditional to determine if a specific URI or URL is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_user_not_logged_in() Conditional to determine if the current User is NOT logged in. public str s2member_file_download_key(str $file, str|bool $directive) Generates a File Download Key that provides access to a File protected by s2Member. public int s2member_paid_registration_time(str $level, int $user_id) Retrieves a Paid Registration Time for the current User, and/or for a particular User. public bool s2member_pro_authnet_s2p_v_query_ok(str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. public str s2member_pro_login_widget(array $options, array $args) Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file. public bool s2member_pro_paypal_s2p_v_query_ok(str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. public int s2member_registration_time(int $user_id) Obtains the Registration Time for the current User, and/or for a particular User. public bool user_cannot(int|str $id, str $capability) Conditional to determine if a specific User does NOT have a specific Capability or Role. public bool user_is(int|str $id, str $role) Conditional to determine if a specific User is/has a specific Role. public bool user_is_not(int|str $id, str $role) Conditional to determine if a specific User is/does NOT have a specific Role. ( 32 Functions )Function Detail s2member\includes\functions\api-functions.inc.php at line #2178 S2MEMBER_VALUE_FOR_PP_INV() public str S2MEMBER_VALUE_FOR_PP_INV () Can be used to auto-fill the invoice for PayPal® Button Codes, with a unique Code~IP combination. PHP Code Sample ?php echo S2MEMBER_VALUE_FOR_PP_INV( ) ; ? Shortcode & JavaScript Equivalents [s2Get constant="S2MEMBER_VALUE_FOR_PP_INV" /]/ppscript type="text/javascript" document.write(S2MEMBER_VALUE_FOR_PP_INV_GEN()); /script Since: 110720 Returns: str - A unique Invoice. See Also: s2Member\API_Constants → S2MEMBER_VALUE_FOR_PP_INV Todo: Create a true Shortcode equivalent function. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1799 attach_s2member_query_filters() public null attach_s2member_query_filters () Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. This functionality is already built right into s2Member's UI configuration panels, but in cases where a plugin/theme developer needs more control, this may come in handy. In the UI configuration for s2Member, please see: Alternative View Protection. Code Sample Using s2Member's Query Filters ?php attach_s2member_query_filters( ) ; query_posts ( "posts_per_page=5" ) ; if ( have_posts ( ) ) : while ( have_posts ( ) ) : the_post ( ) ; # Protected content will be excluded automatically. # ( based on the current User's Role/Capabilities ) endwhile ; endif ; wp_reset_query ( ) ; detach_s2member_query_filters( ) ; ? Shortcode Equivalent There is NO Shortcode equivalent for this. Since: 3.5 Returns: null See Also: s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #678 current_user_cannot() public bool current_user_cannot (str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( current_user_can ( "access_s2member_level0" ) ) echo 'You CAN access content protected at Level #0.' ; else if (current_user_cannot( "access_s2member_level0" ) ) echo 'You CANNOT access content protected at Level #0.' ; ? Shortcode Conditional Equivalent [s2If current_user_can(access_s2member_level0)] You CAN access content protected at Level #0. [/s2If] [s2If current_user_cannot(access_s2member_level0)] You CANNOT access content protected at Level #0. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Or a Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #748 current_user_cannot_for_blog() public bool current_user_cannot_for_blog (int|str $blog_id, str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( current_user_can_for_blog ( 5 , "access_s2member_level0" ) ) echo 'You CAN access content protected at Level #0 ( on Blog ID 5 ).' ; else if (current_user_cannot_for_blog( 5 , "access_s2member_level0" ) ) echo 'You CANNOT access content protected at Level #0 ( on Blog ID 5 ).' ; ? Shortcode Conditional Equivalent [s2If current_user_can_for_blog(5, access_s2member_level0)] You CAN access content protected at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_cannot_for_blog(5, access_s2member_level0)] You CANNOT access content protected at Level #0 ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Or a Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #294 current_user_is() public bool current_user_is (str $role) Conditional to determine if the current User is/has a specific Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0.' ; else if (current_user_is( "s2member_level1" ) ) echo 'You ARE a Member at Level #1.' ; else if ( current_user_can ( "access_s2member_level2" ) ) echo 'You DO have access to content protected at Level #2.' ; # But, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If curent_user_is(subscriber)] You ARE a Free Subscriber at Level #0. [/s2If] [s2If curent_user_is(s2member_level1)] You ARE a Member at Level #1. [/s2If] [s2If current_user_can(access_s2member_level2)] You DO have access to content protected at Level #2. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/has the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #461 current_user_is_for_blog() public bool current_user_is_for_blog (int|str $blog_id, str $role) Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on this Blog ).' ; else if (current_user_is_for_blog( 5 , "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ).' ; else if (current_user_is_for_blog( 5 , "s2member_level1" ) ) echo 'You ARE a Member at Level #1 ( on Blog ID 5 ).' ; else if ( current_user_can_for_blog ( 5 , "access_s2member_level2" ) ) echo 'You DO have access to content protected at Level #2 ( on Blog ID 5 ).' ; # But, (important) they could actually be a Level #3 or #4 Member ( on Blog ID 5 ); # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is(subscriber)] You ARE a Free Subscriber at Level #0 ( on this Blog ). [/s2If] [s2If current_user_is_for_blog(5, subscriber)] You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_is_for_blog(5, s2member_level1)] You ARE a Member at Level #1 ( on Blog ID 5 ). [/s2If] [s2If current_user_can_for_blog(5, access_s2member_level2)] You DO have access to content protected at Level #2 ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/has the specified Role, on the specified Blog, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #378 current_user_is_not() public bool current_user_is_not (str $role) Conditional to determine if the current User is/does NOT have a specific Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0.' ; else if (current_user_is( "s2member_level1" ) ) echo 'You ARE a Member at Level #1.' ; else if ( current_user_can ( "access_s2member_level2" ) && current_user_is_not( "s2member_level2" ) ) echo 'You DO have access to content protected at Level #2, but you are NOT a Level #2 Member.' ; # So, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is(subscriber)] You ARE a Free Subscriber at Level #0. [/s2If] [s2If current_user_is(s2member_level1)] You ARE a Member at Level #1. [/s2If] [s2If current_user_can(access_s2member_level2) AND current_user_is_not(s2member_level2)] You DO have access to content protected at Level #2, but you are NOT a Level #2 Member. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/does NOT have the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #540 current_user_is_not_for_blog() public bool current_user_is_not_for_blog (int|str $blog_id, str $role) Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is_for_blog( 5 , "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ).' ; else if ( current_user_can_for_blog ( 5 , "access_s2member_level1" ) && current_user_is_not_for_blog( 5 , "s2member_level1" ) ) echo 'You DO have access to content protected at Level #1 ( on Blog ID 5 ), but you are NOT a Level #1 Member ( on Blog ID 5 ).' ; # So, (important) they could actually be a Level #2 or #3 or #4 Member ( on Blog ID 5 ); # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is_for_blog(5, subscriber)] You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_can_for_blog(5, access_s2member_level1) AND current_user_is_not_for_blog(5, s2member_level1)] You DO have access to content protected at Level #1 ( on Blog ID 5 ), but you are NOT a Level #1 Member ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/does NOT have the specified Role, on the specified Blog, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1845 detach_s2member_query_filters() public null detach_s2member_query_filters () Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. This functionality is already built right into s2Member's UI configuration panels, but in cases where a plugin/theme developer needs more control, this may come in handy. In the UI configuration for s2Member, please see: Alternative View Protection. Code Sample Using s2Member's Query Filters ?php attach_s2member_query_filters( ) ; query_posts ( "posts_per_page=5" ) ; if ( have_posts ( ) ) : while ( have_posts ( ) ) : the_post ( ) ; # Protected content will be excluded automatically. # ( based on the current User's Role/Capabilities ) endwhile ; endif ; wp_reset_query ( ) ; detach_s2member_query_filters( ) ; ? Shortcode Equivalent There is NO Shortcode equivalent for this. Since: 3.5 Returns: null See Also: s2Member\API_Functions → attach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #2146 get_user_field() public mixed get_user_field (str $field_id, int $user_id) A powerful function that can retrieve almost anything you need to know about the current User, and/or a particular User. Scans all properties of the WP_User object. It defaults to the current User, but can also be used to obtain information about a particular User, by passing in a specific User ID. It can be used to retrieve basic information like first_name, last_name, user_email, user_login. It can also be used to retrieve User Meta/Options, Role/Capabilities, and even supports Custom Registration Fields configured with s2Member and many other plugins. Here Are A Few Examples ?php $user_login = get_user_field ( "user_login" ) ; # Username for the current User. $user_email = get_user_field ( "user_email" ) ; # Email Address for the current User. $first_name = get_user_field ( "first_name" ) ; # First Name for the current User. $last_name = get_user_field ( "last_name" ) ; # Last Name for the current User. $full_name = get_user_field ( "full_name" ) ; # First and Last Name for the current User. $display_name = get_user_field ( "display_name" ) ; # Display Name for the current User. ? Shortcode Equivalents [s2Get user_field="user_login" /] # Username for the current User. [s2Get user_field="user_email" /] # Email Address for the current User. [s2Get user_field="first_name" /] # First Name for the current User. [s2Get user_field="last_name" /] # Last Name for the current User. [s2Get user_field="full_name" /] # First and Last Name for the current User. [s2Get user_field="display_name" /] # Display Name for the current User. More Examples With s2Member Fields ?php $s2member_custom = get_user_field ( "s2member_custom" ) ; # Custom String value for the current User. $s2member_subscr_id = get_user_field ( "s2member_subscr_id" ) ; # Paid Subscr. ID for the current User. $s2member_subscr_or_wp_id = get_user_field ( "s2member_subscr_or_wp_id" ) ; # Paid Subscr. ID, else WordPress® User ID. $s2member_subscr_gateway = get_user_field ( "s2member_subscr_gateway" ) ; # Paid Subscr. Gateway Code for the current User. $s2member_registration_ip = get_user_field ( "s2member_registration_ip" ) ; # IP the current User had during registration. $s2member_custom_fields = get_user_field ( "s2member_custom_fields" ) ; # Associative array of all Custom Registration Fields. $s2member_file_download_access_log = get_user_field ( "s2member_file_download_access_log" ) ; # Associative array of all File Downloads by the current User. $s2member_auto_eot_time = get_user_field ( "s2member_auto_eot_time" ) ; # Auto EOT-Time for the current User ( when applicable ). $s2member_last_payment_time = get_user_field ( "s2member_last_payment_time" ) ; # Timestamp. Last time an actual payment was received by s2Member. $s2member_paid_registration_times = get_user_field ( "s2member_paid_registration_times" ) ; # Timestamps. Associative array of all Paid Registration Times. $s2member_access_role = get_user_field ( "s2member_access_role" ) ; # A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). $s2member_access_level = get_user_field ( "s2member_access_level" ) ; # An s2Member Membership Access Level number. $s2member_access_label = get_user_field ( "s2member_access_label" ) ; # An s2Member Membership Access Label ( i.e. Bronze, Gold, Silver, Platinum, or whatever is configured ). $s2member_access_ccaps = get_user_field ( "s2member_access_ccaps" ) ; # An array of Custom Capabilities the current User has ( i.e. music,videos ). $s2member_login_counter = get_user_field ( "s2member_login_counter" ) ; # Number of times the User has logged into your site. ? Practical Shortcode Equivalents [s2Get user_field="s2member_custom" /] # Custom String value for the current User. [s2Get user_field="s2member_subscr_id" /] # Paid Subscr. ID for the current User. [s2Get user_field="s2member_subscr_or_wp_id" /] # Paid Subscr. ID, else WordPress® User ID. [s2Get user_field="s2member_subscr_gateway" /] # Paid Subscr. Gateway Code for the current User. [s2Get user_field="s2member_registration_ip" /] # IP Address the current User had during registration. [s2Get user_field="s2member_access_role" /] # A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). [s2Get user_field="s2member_access_level" /] # An s2Member Membership Access Level number. [s2Get user_field="s2member_access_label" /] # An s2Member Membership Access Label ( i.e. Bronze, Gold, Silver, Platinum, or whatever is configured ). [s2Get user_field="s2member_login_counter" /] # Number of times the User has logged into your site. Pulling Data From Your Own Custom Fields ?php $my_field_data = get_user_field ( "my_field_id" ) ; # The Unique Field ID you configured with s2Member. ? Shortcode Equivalent [s2Get user_field="my_field_id" /] # The Unique Field ID you configured with s2Member. Pulling Data For A Particular User ID ?php $user_login = get_user_field ( "user_login" , 123 ) ; # Username for the User with ID #123. $user_email = get_user_field ( "user_email" , 123 ) ; # Email Address for the User with ID #123. $first_name = get_user_field ( "first_name" , 123 ) ; # First Name for the User with ID #123. $last_name = get_user_field ( "last_name" , 123 ) ; # Last Name for the User with ID #123. $full_name = get_user_field ( "full_name" , 123 ) ; # First and Last Name for the User with ID #123. $display_name = get_user_field ( "display_name" , 123 ) ; # Display Name for the User with ID #123. ? Shortcode Equivalents [s2Get user_field="user_login" user_id="123" /] # Username for the User with ID #123. [s2Get user_field="user_email" user_id="123" /] # Email Address for the User with ID #123. [s2Get user_field="first_name" user_id="123" /] # First Name for the User with ID #123. [s2Get user_field="last_name" user_id="123" /] # Last Name for the User with ID #123. [s2Get user_field="full_name" user_id="123" /] # First and Last Name for the User with ID #123. [s2Get user_field="display_name" user_id="123" /] # Display Name for the User with ID #123. Finding A User ID, Based On Username ?php $user = new WP_User ( "johndoe22" ) ; $user_id = $user - ID ; ? Finding A Username, Based On User ID ?php $user = new WP_User ( 123 ) ; $user_login = $user - user_login ; # Or you could just use this alternate method. $user_login = get_user_field ( "user_login" , 123 ) ; ? Alternative Using get_user_option ( ) Native To WordPress® Most of the s2Member fields are stored in the usermeta table ( a WordPress® standard ), so they could also be retrieved with WordPress® Function → get_user_option() if you prefer, which is already native to WordPress®. That being said, s2Member\API_Functions → get_user_field() is provided by s2Member as a way to retrieve almost anything. ?php $s2member_custom = get_user_option ( "s2member_custom" ) ; # Custom String value for the current User. $s2member_subscr_id = get_user_option ( "s2member_subscr_id" ) ; # Paid Subscr. ID for the current User. $s2member_subscr_gateway = get_user_option ( "s2member_subscr_gateway" ) ; # Paid Subscr. Gateway Code for the current User. $s2member_registration_ip = get_user_option ( "s2member_registration_ip" ) ; # IP the current User had during registration. $s2member_custom_fields = get_user_option ( "s2member_custom_fields" ) ; # Associative array of all Custom Registration Fields. $s2member_file_download_access_log = get_user_option ( "s2member_file_download_access_log" ) ; # Associative array of all File Downloads by the current User. $s2member_auto_eot_time = get_user_option ( "s2member_auto_eot_time" ) ; # Auto EOT-Time for the current User ( when applicable ). $s2member_last_payment_time = get_user_option ( "s2member_last_payment_time" ) ; # Timestamp. Last time an actual payment was received by s2Member. $s2member_paid_registration_times = get_user_option ( "s2member_paid_registration_times" ) ; # Timestamps. Associative array of all Paid Registration Times. $s2member_login_counter = get_user_option ( "s2member_login_counter" ) ; # Number of times the User has logged into your site. ? Practical Shortcode Equivalents [s2Get user_option="s2member_custom" /] # Custom String value for the current User. [s2Get user_option="s2member_subscr_id" /] # Paid Subscr. ID for the current User. [s2Get user_option="s2member_subscr_gateway" /] # Paid Subscr. Gateway Code for the current User. [s2Get user_option="s2member_registration_ip" /] # IP the current User had during registration. [s2Get user_option="s2member_login_counter" /] # Number of times the User has logged in. Since: 3.5 Parameters: str $field_id - Required. A unique Custom Registration Field ID, that you configured with s2Member. Or, this could be set to any property that exists on the WP_User object for a particular User; ( i.e. id, ID, user_login, user_email, first_name, last_name, display_name, ip, IP, s2member_registration_ip, s2member_custom, s2member_subscr_id, s2member_subscr_or_wp_id, s2member_subscr_gateway, s2member_custom_fields, s2member_file_download_access_log, s2member_auto_eot_time, s2member_last_payment_time, s2member_paid_registration_times, s2member_access_role, s2member_access_level, s2member_access_label, s2member_access_ccaps, s2member_login_counter, etc, etc. ). int $user_id - Optional. Defaults to the current User's ID. Returns: mixed - The value of the requested field, or false if the field does not exist. See Also: s2Member\API_Functions → s2member_registration_time() s2Member\API_Functions → s2member_paid_registration_time() WordPress® Function → get_user_option() WordPress® Function → update_user_option() WordPress® Function → wp_get_current_user() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1139 is_category_permitted_by_s2member() public bool is_category_permitted_by_s2member (int $cat_id) Conditional to determine if a specific Category is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_category_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_category_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $cat_id ( int Required ). This should be a WordPress® Category ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_category_permitted_by_s2member( 123 ) ) echo 'Category ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_category_permitted_by_s2member(123)] Category ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $cat_id - Required. This should be a WordPress® Category ID. Returns: bool - True if the current User IS permitted, else false if the Category is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1071 is_category_protected_by_s2member() public array|bool is_category_protected_by_s2member (int $cat_id, bool $check_user) Conditional to determine if a specific Category is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $cat_id ( int Required ). This should be a WordPress® Category ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Category is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_category_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_category_protected_by_s2member( 123 ) ) echo 'Category ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_category_protected_by_s2member(123)] Category ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $cat_id - Required. This should be a WordPress® Category ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Category is not protected ( i.e. available publicly ). When/if the Category IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Category. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1594 is_page_permitted_by_s2member() public bool is_page_permitted_by_s2member (int $page_id) Conditional to determine if a specific Page is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_page_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_page_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $page_id ( int Required ). This should be a WordPress® Page ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_page_permitted_by_s2member( 123 ) ) echo 'Page ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_page_permitted_by_s2member(123)] Page ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $page_id - Required. This should be a WordPress® Page ID. Returns: bool - True if the current User IS permitted, else false if the Page is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1526 is_page_protected_by_s2member() public array|bool is_page_protected_by_s2member (int $page_id, bool $check_user) Conditional to determine if a specific Page is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $page_id ( int Required ). This should be a WordPress® Page ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Page is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_page_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_page_protected_by_s2member( 123 ) ) echo 'Page ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_page_protected_by_s2member(123)] Page ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $page_id - Required. This should be a WordPress® Page ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Page is not protected ( i.e. available publicly ). When/if the Page IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Page. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #979 is_permitted_by_s2member() public bool is_permitted_by_s2member (int|str $what, str $type) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $what ( int|str Optional ). Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. If you pass in an ID, s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. If you pass in a URL or URI, s2Member will ONLY check URI Restrictions, because it has no ID to work with. This is useful though. Some protected content is not associated with an ID. In those cases, URI Restrictions are all the matter. Note: when passing in a URL or URI, the $type parameter must be set to URI or uri. Case insensitive. Parameter $type ( str Optional ). One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Code Sample Using Function Parameters ?php if (is_permitted_by_s2member( 123 ) ) echo 'Post or Page ID #123 is permitted by s2Member.' ; else if (is_permitted_by_s2member( 332 , "tag" ) ) echo 'Tag ID #332 is permitted by s2Member.' ; else if (is_permitted_by_s2member( 554 , "category" ) ) echo 'Category ID #554 is permitted by s2Member.' ; else if (is_permitted_by_s2member( "http://example.com/members/" , "uri" ) ) echo 'This URL is permitted by s2Member.' ; else if (is_permitted_by_s2member( "/members/" , "uri" ) ) echo 'This URI is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_permitted_by_s2member(123)] Post or Page ID #123 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(332, tag)] Tag ID #332 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(554, category)] Category ID #554 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(http://example.com/members/, uri)] This URL is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(/members/, uri)] This URI is permitted by s2Member. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $what - Optional. Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. str $type - Optional. One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Returns: bool - True if the current User IS permitted, else false if the content is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1451 is_post_permitted_by_s2member() public bool is_post_permitted_by_s2member (int $post_id) Conditional to determine if a specific Post or Custom Post Type is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_post_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_post_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $post_id ( int Required ). This should be a WordPress® Post ID, or a Custom Post Type ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_post_permitted_by_s2member( 123 ) ) echo 'Post ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_post_permitted_by_s2member(123)] Post ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID. Returns: bool - True if the current User IS permitted, else false if the Post is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1383 is_post_protected_by_s2member() public array|bool is_post_protected_by_s2member (int $post_id, bool $check_user) Conditional to determine if a specific Post ( or Custom Post Type ) is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $post_id ( int Required ). This should be a WordPress® Post ID, or a Custom Post Type ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Post is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_post_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_post_protected_by_s2member( 123 ) ) echo 'Post ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_post_protected_by_s2member(123)] Post ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Post is not protected ( i.e. available publicly ). When/if the Post IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Post. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #857 is_protected_by_s2member() public array|bool is_protected_by_s2member (int|str $what, str $type, bool $check_user) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $what ( int|str Optional ). Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. If you pass in an ID, s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. If you pass in a URL or URI, s2Member will ONLY check URI Restrictions, because it has no ID to work with. This is useful though. Some protected content is not associated with an ID. In those cases, URI Restrictions are all the matter. Note: when passing in a URL or URI, the $type parameter must be set to URI or uri. Case insensitive. Parameter $type ( str Optional ). One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the content is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_protected_by_s2member( 123 ) ) echo 'Post or Page ID #123 is protected by s2Member.' ; else if (is_protected_by_s2member( 332 , "tag" ) ) echo 'Tag ID #332 is protected by s2Member.' ; else if (is_protected_by_s2member( 554 , "category" ) ) echo 'Category ID #554 is protected by s2Member.' ; else if (is_protected_by_s2member( "http://example.com/members/" , "uri" ) ) echo 'This URL is protected by URI Restrictions.' ; else if (is_protected_by_s2member( "/members/" , "uri" ) ) echo 'This URI is protected by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_protected_by_s2member(123)] Post or Page ID #123 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(332, tag)] Tag ID #332 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(554, category)] Category ID #554 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(http://example.com/members/, uri)] This URL is protected by URI Restrictions. [/s2If] [s2If is_protected_by_s2member(/members/, uri)] This URI is protected by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $what - Optional. Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. str $type - Optional. One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the content is not protected ( i.e. available publicly ). When/if content IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the content. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1308 is_tag_permitted_by_s2member() public bool is_tag_permitted_by_s2member (int|str $tag_id_slug_or_name) Conditional to determine if a specific Tag is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_tag_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_tag_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $tag_id_slug_or_name ( int|str Required ). This should be a WordPress® Tag ID, Tag Slug, or Tag Name. s2Member will check everything, including your configured URI Restrictions against the ID, or Slug, or Name. In other words, s2Member is capable of determining a URI based on the ID, or Slug, or Name that you pass in. So using an ID, or Slug, or Name results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_tag_permitted_by_s2member( 123 ) ) echo 'Tag ID #123 is permitted by s2Member.' ; else if (is_tag_permitted_by_s2member( "members-only" ) ) echo 'Tag Slug (members-only) is permitted by s2Member.' ; else if (is_tag_permitted_by_s2member( "Members Only" ) ) echo 'Tag Name (Members Only) is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_tag_permitted_by_s2member(123)] Tag ID #123 is permitted by s2Member. [/s2If] [s2If is_tag_permitted_by_s2member(members-only)] Tag Slug (members-only) is permitted by s2Member. [/s2If] NOTE: It's NOT possible to check a Tag Named "Members Only" with [s2If /], because Shortcode Conditionals may NOT contain spaces in their argument values. If you're using [s2If /] to check a Tag, please use the Slug or ID instead. *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name. Returns: bool - True if the current User IS permitted, else false if the Tag is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1227 is_tag_protected_by_s2member() public array|bool is_tag_protected_by_s2member (int|str $tag_id_slug_or_name, bool $check_user) Conditional to determine if a specific Tag is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $tag_id_slug_or_name ( int|str Required ). This should be a WordPress® Tag ID, Tag Slug, or Tag Name. s2Member will check everything, including your configured URI Restrictions against the ID, Slug, or Name. In other words, s2Member is capable of determining a URI based on the ID, or Slug, or Name that you pass in. So using an ID, or Slug, or Name results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Tag is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_tag_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_tag_protected_by_s2member( 123 ) ) echo 'Tag ID #123 is protected by s2Member.' ; else if (is_tag_protected_by_s2member( "members-only" ) ) echo 'Tag Slug (members-only) is protected by s2Member.' ; else if (is_tag_protected_by_s2member( "Members Only" ) ) echo 'Tag Name (Members Only) is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_tag_protected_by_s2member(123)] Tag ID #123 is protected by s2Member. [/s2If] [s2If is_tag_protected_by_s2member(members-only)] Tag Slug (members-only) is protected by s2Member. [/s2If] NOTE: It's NOT possible to check a Tag Named "Members Only" with [s2If /], because Shortcode Conditionals may NOT contain spaces in their argument values. If you're using [s2If /] to check a Tag, please use the Slug or ID instead. *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Tag is not protected ( i.e. available publicly ). When/if the Tag IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Tag. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1751 is_uri_permitted_by_s2member() public bool is_uri_permitted_by_s2member (str $uri_or_full_url) Conditional to determine if a specific URI or URL is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_uri_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_uri_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $uri_or_full_url ( str Required ). This should be a URI starting with /, or a full URL is also fine. Important Notes About This Function This function will ONLY test against URI Restrictions you've configured with s2Member. If you need an all-inclusive test, please use s2Member\API_Functions → is_permitted_by_s2member() with an ID. Code Sample Using Function Parameters ?php if (is_uri_permitted_by_s2member( "/members-only/sub-section" ) ) echo 'The URI (/members-only/sub-section) is permitted by URI Restrictions.' ; else if (is_uri_permitted_by_s2member( "http://example.com/members-only/sub-section" ) ) echo 'The URL (http://example.com/members-only/sub-section) is permitted by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_uri_permitted_by_s2member(/members-only/sub-section)] The URI (/members-only/sub-section) is permitted by URI Restrictions. [/s2If] [s2If is_uri_permitted_by_s2member(http://example.com/members-only/sub-section)] The URL (http://example.com/members-only/sub-section) is permitted by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: str $uri_or_full_url - Required. This should be a URI starting with /, or a full URL is also fine. Returns: bool - True if the current User IS permitted, else false if the URI or URL is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1676 is_uri_protected_by_s2member() public array|bool is_uri_protected_by_s2member (str $uri_or_full_url, bool $check_user) Conditional to determine if a specific URI or URL is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $uri_or_full_url ( str Required ). This should be a URI starting with /, or a full URL is also fine. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the URI or URL is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_uri_permitted_by_s2member(). Important Notes About This Function This function will ONLY test against URI Restrictions you've configured with s2Member. If you need an all-inclusive test, please use s2Member\API_Functions → is_protected_by_s2member() with an ID. Code Sample Using Function Parameters ?php if (is_uri_protected_by_s2member( "/members-only/sub-section" ) ) echo 'The URI (/members-only/sub-section) is protected by URI Restrictions.' ; else if (is_uri_protected_by_s2member( "http://example.com/members-only/sub-section" ) ) echo 'The URL (http://example.com/members-only/sub-section) is protected by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_uri_protected_by_s2member(/members-only/sub-section)] The URI (/members-only/sub-section) is protected by URI Restrictions. [/s2If] [s2If is_uri_protected_by_s2member(http://example.com/members-only/sub-section)] The URL (http://example.com/members-only/sub-section) is protected by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: str $uri_or_full_url - Required. This should be a URI starting with /, or a full URL is also fine. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the URI or URL is not protected ( i.e. available publicly ). When/if the URI or URL IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the URI or URL. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #54 is_user_not_logged_in() public bool is_user_not_logged_in () Conditional to determine if the current User is NOT logged in. Counterpart WordPress® Function → is_user_logged_in() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( is_user_logged_in ( ) ) echo 'You ARE logged in.' ; else if (is_user_not_logged_in( ) ) echo 'You are NOT logged in.' ; ? Shortcode Conditional Equivalent [s2If is_user_logged_in()] You ARE logged in. [/s2If] [s2If is_user_not_logged_in()] You are NOT logged in. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Returns: bool - True if the current User is NOT logged in, else false. See Also: WordPress® Function → is_user_logged_in() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1897 s2member_file_download_key() public str s2member_file_download_key (str $file, str|bool $directive) Generates a File Download Key that provides access to a File protected by s2Member. By default, s2Member uses your Basic Download Restrictions. For more information on this, please check your Dashboard under: s2Member - Download Options - Basic Download Restrictions. Advanced Download Restrictions Or, you can also force s2Member to allow File Downloads, using an extra query string parameter s2member_file_download_key. A File Download Key is passed through this parameter; it tells s2Member to allow the download of this particular file, regardless of Membership Level; and WITHOUT checking any Basic Restrictions, that you may, or may not, have configured. Code Sample Using A Download Key a href="/?s2member_file_download=file.zip&s2member_file_download_key=?php echo s2member_file_download_key( "file.zip" ) ; ?"Download Now/a Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). This API Funtion produces a time-sensitive File Download Key that is unique to each and every visitor. Each Key it produces ( at the time it is produced ), will be valid for the current day, and only for a specific IP address and User-Agent string; as detected by s2Member. This makes it possible for you to create links on your site, which provide access to protected File Downloads; without having to worry about one visitor sharing their link with another. When /?s2member_file_download_key = a valid Key generated by this function, it works independently from Member Level Access. That is, a visitor does NOT have to be logged in to receive access; they just need a valid Key. Using this advanced technique, you could extend s2Member's file protection routines, or even combine them with Specific Post/Page Access, and more. The possibilities are limitless really. Since: 3.5 Parameters: str $file - Location of the protected File, relative to the /s2member-files/ directory. str|bool $directive - Optional. Defaults to false. If you set this to any non-zero value ( i.e. the string universal ), the resulting Key will be universal ( i.e. valid for any User, at any time, from any browser ). That is to say; universal, for this particular File. It is also possible to pass in the $directive string ip-forever, making the Key last forever, but only for a specific IP address. Returns: str - The File Download Key. Which is an MD5 hash ( always 32 characters ), URL-safe. Todo: Create a Shortcode equivalent. Allow custom expiration times. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1981 s2member_paid_registration_time() public int s2member_paid_registration_time (str $level, int $user_id) Retrieves a Paid Registration Time for the current User, and/or for a particular User. NOTE A Paid Registration Time, is NOT necessarily related specifically to a Payment. s2Member records a Paid Registration Time, anytime a User acquires paid Membership Level Access. In other words, if you create a new User inside your Dashboard at a Membership Level greater than Level #0, s2Member will record a Paid Registration Time immediately, because Membership Levels 0, are reserved for paying Members. s2Member monitors changes to all User accounts, and records the first Paid Registration Time for each Member, at each paid Membership Level. So, s2Member stores the first Time a Member reaches each Level of paid access; and s2Member does NOT care if they actually paid, or not. Code Sample Using Function Parameters ?php $time = s2member_registration_time ( ) ; # first registration time ( free or otherwise ). $time = s2member_paid_registration_time ( ) ; # first "paid" registration and/or upgrade time. $time = s2member_paid_registration_time ( "level1" ) ; # first "paid" registration or upgrade time at Level#1. $time = s2member_paid_registration_time ( "level2" ) ; # first "paid" registration or upgrade time at Level#2. $time = s2member_paid_registration_time ( "level3" ) ; # first "paid" registration or upgrade time at Level#3. $time = s2member_paid_registration_time ( "level4" ) ; # first "paid" registration or upgrade time at Level#4. ? Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). Since: 3.5 Parameters: str $level - Optional. Defaults to the first/initial Paid Registration Time, regardless of Level#. int $user_id - Optional. Defaults to the current User's ID. Returns: int - A Unix Timestamp. See Also: s2Member\API_Functions → get_user_field() Todo: Create a Shortcode equivalent. [ back to top ] s2member-pro\includes\functions\separates\gateways\authnet\authnet-api-functions.inc.php at line #50 s2member_pro_authnet_s2p_v_query_ok() public bool s2member_pro_authnet_s2p_v_query_ok (str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. This can be used for verifying the integrity of variables in a success query string. Example usage: if (s2member_pro_authnet_s2p_v_query_ok( $_SERVER [ "QUERY_STRING" ] ) ) { } Since: 1.5 Parameters: str $qs - Optional. Defaults to $_SERVER [ "QUERY_STRING" ] . book $ignore_timestamp - Optional. If true, timestamp is ignored. Defaults to false. Returns: bool - True if the query string is OK/verified, else false. [ back to top ] s2member-pro\includes\functions\api-functions.inc.php at line #104 s2member_pro_login_widget() public str s2member_pro_login_widget (array $options, array $args) Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file. This function will return the HTML output from the widget function call. Example usage: ?php echo s2member_pro_login_widget( ) ; ? The $options parameter (array) is completely optional ( i.e. NOT required ). It can be passed in as an array of options; overriding some or all of these defaults: "title" = "Membership Login" Title when NOT logged in, or leave this blank if you'd prefer not to show a title. "signup_url" = "%%automatic%%" Full Signup URL, or use %%automatic%% for the Membership Options Page. If you leave this blank, it will not be shown. "login_redirect" = "" Empty ( i.e. "" ) = Login Welcome Page, %%previous%% = Previous Page, %%home%% = Home Page, or use a full URL of your own. "logged_out_code" = "" HTML/PHP code to display when logged out. May also contain WP Shortcodes if you like. "profile_title" = "My Profile Summary" Title when a User is logged in. Or you can leave this blank if you'd prefer not to show a title. "display_gravatar" = "1" Display Gravatar image when logged in? 1 = yes, 0 = no. Gravatars are based on email address. "link_gravatar" = "1" Link Gravatar image to Gravatar.com? 1 = yes, 0 = no. Allows Users to setup a Gravatar. "display_name" = "1" Display the current User's WordPress® "Display Name" when logged in? 1 = yes, 0 = no. "logged_in_code" = "" HTML/PHP code to display when logged in. May also contain WP Shortcodes if you like. "logout_redirect" = "%%home%%" Empty ( i.e. "" ) = Login Screen, %%previous%% = Previous Page, %%home%% = Home Page, or use a full URL of your own. "my_account_url" = "%%automatic%%" Full URL of your own, or use %%automatic%% for the Login Welcome Page. Leave empty to not show this at all. "my_profile_url" = "%%automatic%%" Full URL of your own, or use %%automatic%% for a JavaScript popup. Leave empty to not show this at all. The $args parameter (array) is also completely optional ( i.e. NOT required ). It can be passed in as an array of options: overriding some or all of these defaults: "before_widget" = "" HTML code to display before the widget. "before_title" = "h3" HTML code to display before the title. "after_title" = "/h3" HTML code to display after the title. "after_widget" = "" HTML code to display after the widget. Since: 1.5 Parameters: array $options - Optional. See function description for details. array $args - Optional. See function description for details. Returns: str - The Pro Login Widget, HTML markup. [ back to top ] s2member-pro\includes\functions\separates\gateways\paypal\paypal-api-functions.inc.php at line #50 s2member_pro_paypal_s2p_v_query_ok() public bool s2member_pro_paypal_s2p_v_query_ok (str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. This can be used for verifying the integrity of variables in a success query string. Example usage: if (s2member_pro_paypal_s2p_v_query_ok( $_SERVER [ "QUERY_STRING" ] ) ) { } Since: 1.5 Parameters: str $qs - Optional. Defaults to $_SERVER [ "QUERY_STRING" ] . book $ignore_timestamp - Optional. If true, timestamp is ignored. Defaults to false. Returns: bool - True if the query string is OK/verified, else false. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1936 s2member_registration_time() public int s2member_registration_time (int $user_id) Obtains the Registration Time for the current User, and/or for a particular User. The Registration Time, is the time at which the Username was created for the account, that's it. There's nothing special about this. This simply returns a Unix Timestamp. Code Sample Using Function Parameters ?php if (s2member_registration_time( ) = strtotime ( "-30 days" ) ) echo 'The current User has existed for at least 30 days.' ; else if (s2member_registration_time( 123 ) = strtotime ( "-30 days" ) ) echo 'User with ID #123 has existed for at least 30 days.' ; ? Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). Since: 3.5 Parameters: int $user_id - Optional. Defaults to the current User's ID. Returns: int - A Unix Timestamp. The Registration Time, is the time at which the Username was created for the account, that's it. See Also: s2Member\API_Functions → get_user_field() Todo: Create a Shortcode equivalent. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #609 user_cannot() public bool user_cannot (int|str $id, str $capability) Conditional to determine if a specific User does NOT have a specific Capability or Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (user_can( 123 , "access_s2member_level0" ) ) echo 'User ID# 123 CAN access content protected at Level #0.' ; else if (user_cannot( 123 , "access_s2member_level0" ) ) echo 'User ID# 123 CANNOT access content at Level #0.' ; ? Shortcode Conditional Equivalent [s2If user_can(123, access_s2member_level0)] User ID# 123 CAN access content protected at Level #0. [/s2If] [s2If user_cannot(123, access_s2member_level0)] User ID# 123 CANNOT access content at Level #0. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $id - A numeric WordPress® User ID. str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Returns: bool - True if the specific User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #132 user_is() public bool user_is (int|str $id, str $role) Conditional to determine if a specific User is/has a specific Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (user_is( 123 , "subscriber" ) ) echo 'User ID# 123 is a Free Subscriber at Level #0.' ; else if (user_is( 123 , "s2member_level1" ) ) echo 'User ID# 123 is a Member at Level #1.' ; else if (user_can( 123 , "access_s2member_level2" ) ) echo 'User ID# 123 has access to content protected at Level #2.' ; # But, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If user_is(123, subscriber)] User ID# 123 is a Free Subscriber at Level #0. [/s2If] [s2If user_is(123, s2member_level1)] User ID# 123 is a Member at Level #1. [/s2If] [s2If user_can(123, access_s2member_level2)] User ID# 123 has access to content protected at Level #2. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 110524RC Parameters: int|str $id - A numeric WordPress® User ID. str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the specific User is/has the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #217 user_is_not() public bool user_is_not (int|str $id, str $role) Conditional to determine if a specific User is/does NOT have a specific Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (user_is( 123 , "subscriber" ) ) echo 'User ID# 123 is a Free Subscriber at Level #0.' ; else if (user_is( 123 , "s2member_level1" ) ) echo 'User ID# 123 is a Member at Level #1.' ; else if (user_can( 123 , "access_s2member_level2" ) && user_is_not( 123 , "s2member_level2" ) ) echo 'User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member.' ; # So, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If user_is(123, subscriber)] User ID# 123 is a Free Subscriber at Level #0. [/s2If] [s2If user_is(123, s2member_level1)] User ID# 123 is a Member at Level #1. [/s2If] [s2If user_can(123, access_s2member_level2) AND user_is_not(123, s2member_level2)] User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 110524RC Parameters: int|str $id - A numeric WordPress® User ID. str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the specific User is/does NOT have the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Summary Functions Hooks/Filters Function Summary | Function Detail(!-- :: s-words --)

Statistics: Posted by System Robot — August 15th, 2011, 1:27 pm


]]>
2011-07-11T17:07:13-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=27115#p27115 <![CDATA[s2Member v110710 / Package s2Member\API_Fu...]]>
s2Member v110710
Package s2Member\API_Functions ( Functions )
Docs updated: July 11, 2011, 6:07 pm

Open for public discussion.
(!-- s-words :: --)Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Summary Functions Hooks/Filters Function Summary | Function Detail Package s2Member\API_Functions ( 31 Functions ) ( 31 Functions )Function Summary public null attach_s2member_query_filters() Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. public bool current_user_cannot(str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role. public bool current_user_cannot_for_blog(int|str $blog_id, str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network. public bool current_user_is(str $role) Conditional to determine if the current User is/has a specific Role. public bool current_user_is_for_blog(int|str $blog_id, str $role) Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network. public bool current_user_is_not(str $role) Conditional to determine if the current User is/does NOT have a specific Role. public bool current_user_is_not_for_blog(int|str $blog_id, str $role) Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network. public null detach_s2member_query_filters() Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. public mixed get_user_field(str $field_id, int $user_id) A powerful function that can retrieve almost anything you need to know about the current User, and/or a particular User. public bool is_category_permitted_by_s2member(int $cat_id) Conditional to determine if a specific Category is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_category_protected_by_s2member(int $cat_id, bool $check_user) Conditional to determine if a specific Category is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_page_permitted_by_s2member(int $page_id) Conditional to determine if a specific Page is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_page_protected_by_s2member(int $page_id, bool $check_user) Conditional to determine if a specific Page is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_permitted_by_s2member(int|str $what, str $type) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public bool is_post_permitted_by_s2member(int $post_id) Conditional to determine if a specific Post or Custom Post Type is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_post_protected_by_s2member(int $post_id, bool $check_user) Conditional to determine if a specific Post ( or Custom Post Type ) is protected by s2Member; without considering the current User's Role/Capabilites. public array|bool is_protected_by_s2member(int|str $what, str $type, bool $check_user) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_tag_permitted_by_s2member(int|str $tag_id_slug_or_name) Conditional to determine if a specific Tag is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_tag_protected_by_s2member(int|str $tag_id_slug_or_name, bool $check_user) Conditional to determine if a specific Tag is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_uri_permitted_by_s2member(str $uri_or_full_url) Conditional to determine if a specific URI or URL is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_uri_protected_by_s2member(str $uri_or_full_url, bool $check_user) Conditional to determine if a specific URI or URL is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_user_not_logged_in() Conditional to determine if the current User is NOT logged in. public str s2member_file_download_key(str $file, str|bool $directive) Generates a File Download Key that provides access to a File protected by s2Member. public int s2member_paid_registration_time(str $level, int $user_id) Retrieves a Paid Registration Time for the current User, and/or for a particular User. public bool s2member_pro_authnet_s2p_v_query_ok(str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. public str s2member_pro_login_widget(array $options, array $args) Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file. public bool s2member_pro_paypal_s2p_v_query_ok(str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. public int s2member_registration_time(int $user_id) Obtains the Registration Time for the current User, and/or for a particular User. public bool user_cannot(int|str $id, str $capability) Conditional to determine if a specific User does NOT have a specific Capability or Role. public bool user_is(int|str $id, str $role) Conditional to determine if a specific User is/has a specific Role. public bool user_is_not(int|str $id, str $role) Conditional to determine if a specific User is/does NOT have a specific Role. ( 31 Functions )Function Detail s2member\includes\functions\api-functions.inc.php at line #1781 attach_s2member_query_filters() public null attach_s2member_query_filters () Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. This functionality is already built right into s2Member's UI configuration panels, but in cases where a plugin/theme developer needs more control, this may come in handy. In the UI configuration for s2Member, please see: Alternative View Protection. Code Sample Using s2Member's Query Filters ?php attach_s2member_query_filters( ) ; query_posts ( "posts_per_page=5" ) ; if ( have_posts ( ) ) : while ( have_posts ( ) ) : the_post ( ) ; # Protected content will be excluded automatically. # ( based on the current User's Role/Capabilities ) endwhile ; endif ; wp_reset_query ( ) ; detach_s2member_query_filters( ) ; ? Shortcode Equivalent There is NO Shortcode equivalent for this. Since: 3.5 Returns: null See Also: s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #660 current_user_cannot() public bool current_user_cannot (str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( current_user_can ( "access_s2member_level0" ) ) echo 'You CAN access content protected at Level #0.' ; else if (current_user_cannot( "access_s2member_level0" ) ) echo 'You CANNOT access content protected at Level #0.' ; ? Shortcode Conditional Equivalent [s2If current_user_can(access_s2member_level0)] You CAN access content protected at Level #0. [/s2If] [s2If current_user_cannot(access_s2member_level0)] You CANNOT access content protected at Level #0. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Or a Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #730 current_user_cannot_for_blog() public bool current_user_cannot_for_blog (int|str $blog_id, str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( current_user_can_for_blog ( 5 , "access_s2member_level0" ) ) echo 'You CAN access content protected at Level #0 ( on Blog ID 5 ).' ; else if (current_user_cannot_for_blog( 5 , "access_s2member_level0" ) ) echo 'You CANNOT access content protected at Level #0 ( on Blog ID 5 ).' ; ? Shortcode Conditional Equivalent [s2If current_user_can_for_blog(5, access_s2member_level0)] You CAN access content protected at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_cannot_for_blog(5, access_s2member_level0)] You CANNOT access content protected at Level #0 ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Or a Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #288 current_user_is() public bool current_user_is (str $role) Conditional to determine if the current User is/has a specific Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0.' ; else if (current_user_is( "s2member_level1" ) ) echo 'You ARE a Member at Level #1.' ; else if ( current_user_can ( "access_s2member_level2" ) ) echo 'You DO have access to content protected at Level #2.' ; # But, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If curent_user_is(subscriber)] You ARE a Free Subscriber at Level #0. [/s2If] [s2If curent_user_is(s2member_level1)] You ARE a Member at Level #1. [/s2If] [s2If current_user_can(access_s2member_level2)] You DO have access to content protected at Level #2. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/has the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #449 current_user_is_for_blog() public bool current_user_is_for_blog (int|str $blog_id, str $role) Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on this Blog ).' ; else if (current_user_is_for_blog( 5 , "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ).' ; else if (current_user_is_for_blog( 5 , "s2member_level1" ) ) echo 'You ARE a Member at Level #1 ( on Blog ID 5 ).' ; else if ( current_user_can_for_blog ( 5 , "access_s2member_level2" ) ) echo 'You DO have access to content protected at Level #2 ( on Blog ID 5 ).' ; # But, (important) they could actually be a Level #3 or #4 Member ( on Blog ID 5 ); # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is(subscriber)] You ARE a Free Subscriber at Level #0 ( on this Blog ). [/s2If] [s2If current_user_is_for_blog(5, subscriber)] You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_is_for_blog(5, s2member_level1)] You ARE a Member at Level #1 ( on Blog ID 5 ). [/s2If] [s2If current_user_can_for_blog(5, access_s2member_level2)] You DO have access to content protected at Level #2 ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/has the specified Role, on the specified Blog, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #365 current_user_is_not() public bool current_user_is_not (str $role) Conditional to determine if the current User is/does NOT have a specific Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0.' ; else if (current_user_is( "s2member_level1" ) ) echo 'You ARE a Member at Level #1.' ; else if ( current_user_can ( "access_s2member_level2" ) && current_user_is_not( "s2member_level2" ) ) echo 'You DO have access to content protected at Level #2, but you are NOT a Level #2 Member.' ; # So, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is(subscriber)] You ARE a Free Subscriber at Level #0. [/s2If] [s2If current_user_is(s2member_level1)] You ARE a Member at Level #1. [/s2If] [s2If current_user_can(access_s2member_level2) AND current_user_is_not(s2member_level2)] You DO have access to content protected at Level #2, but you are NOT a Level #2 Member. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/does NOT have the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #521 current_user_is_not_for_blog() public bool current_user_is_not_for_blog (int|str $blog_id, str $role) Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is_for_blog( 5 , "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ).' ; else if ( current_user_can_for_blog ( 5 , "access_s2member_level1" ) && current_user_is_not_for_blog( 5 , "s2member_level1" ) ) echo 'You DO have access to content protected at Level #1 ( on Blog ID 5 ), but you are NOT a Level #1 Member ( on Blog ID 5 ).' ; # So, (important) they could actually be a Level #2 or #3 or #4 Member ( on Blog ID 5 ); # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is_for_blog(5, subscriber)] You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_can_for_blog(5, access_s2member_level1) AND current_user_is_not_for_blog(5, s2member_level1)] You DO have access to content protected at Level #1 ( on Blog ID 5 ), but you are NOT a Level #1 Member ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/does NOT have the specified Role, on the specified Blog, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1827 detach_s2member_query_filters() public null detach_s2member_query_filters () Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. This functionality is already built right into s2Member's UI configuration panels, but in cases where a plugin/theme developer needs more control, this may come in handy. In the UI configuration for s2Member, please see: Alternative View Protection. Code Sample Using s2Member's Query Filters ?php attach_s2member_query_filters( ) ; query_posts ( "posts_per_page=5" ) ; if ( have_posts ( ) ) : while ( have_posts ( ) ) : the_post ( ) ; # Protected content will be excluded automatically. # ( based on the current User's Role/Capabilities ) endwhile ; endif ; wp_reset_query ( ) ; detach_s2member_query_filters( ) ; ? Shortcode Equivalent There is NO Shortcode equivalent for this. Since: 3.5 Returns: null See Also: s2Member\API_Functions → attach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #2124 get_user_field() public mixed get_user_field (str $field_id, int $user_id) A powerful function that can retrieve almost anything you need to know about the current User, and/or a particular User. Scans all properties of the WP_User object. It defaults to the current User, but can also be used to obtain information about a particular User, by passing in a specific User ID. It can be used to retrieve basic information like first_name, last_name, user_email, user_login. It can also be used to retrieve User Meta/Options, Role/Capabilities, and even supports Custom Registration Fields configured with s2Member and many other plugins. Here Are A Few Examples ?php $user_login = get_user_field ( "user_login" ) ; # Username for the current User. $user_email = get_user_field ( "user_email" ) ; # Email Address for the current User. $first_name = get_user_field ( "first_name" ) ; # First Name for the current User. $last_name = get_user_field ( "last_name" ) ; # Last Name for the current User. $full_name = get_user_field ( "full_name" ) ; # First and Last Name for the current User. $display_name = get_user_field ( "display_name" ) ; # Display Name for the current User. ? Shortcode Equivalents [s2Get user_field="user_login" /] # Username for the current User. [s2Get user_field="user_email" /] # Email Address for the current User. [s2Get user_field="first_name" /] # First Name for the current User. [s2Get user_field="last_name" /] # Last Name for the current User. [s2Get user_field="full_name" /] # First and Last Name for the current User. [s2Get user_field="display_name" /] # Display Name for the current User. More Examples With s2Member Fields ?php $s2member_custom = get_user_field ( "s2member_custom" ) ; # Custom String value for the current User. $s2member_subscr_id = get_user_field ( "s2member_subscr_id" ) ; # Paid Subscr. ID for the current User. $s2member_subscr_or_wp_id = get_user_field ( "s2member_subscr_or_wp_id" ) ; # Paid Subscr. ID, else WordPress® User ID. $s2member_subscr_gateway = get_user_field ( "s2member_subscr_gateway" ) ; # Paid Subscr. Gateway Code for the current User. $s2member_registration_ip = get_user_field ( "s2member_registration_ip" ) ; # IP the current User had during registration. $s2member_custom_fields = get_user_field ( "s2member_custom_fields" ) ; # Associative array of all Custom Registration Fields. $s2member_file_download_access_log = get_user_field ( "s2member_file_download_access_log" ) ; # Associative array of all File Downloads by the current User. $s2member_auto_eot_time = get_user_field ( "s2member_auto_eot_time" ) ; # Auto EOT-Time for the current User ( when applicable ). $s2member_last_payment_time = get_user_field ( "s2member_last_payment_time" ) ; # Timestamp. Last time an actual payment was received by s2Member. $s2member_paid_registration_times = get_user_field ( "s2member_paid_registration_times" ) ; # Timestamps. Associative array of all Paid Registration Times. $s2member_access_role = get_user_field ( "s2member_access_role" ) ; # A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). $s2member_access_level = get_user_field ( "s2member_access_level" ) ; # An s2Member Membership Access Level number. $s2member_access_label = get_user_field ( "s2member_access_label" ) ; # An s2Member Membership Access Label ( i.e. Bronze, Gold, Silver, Platinum, or whatever is configured ). $s2member_access_ccaps = get_user_field ( "s2member_access_ccaps" ) ; # An array of Custom Capabilities the current User has ( i.e. music,videos ). ? Practical Shortcode Equivalents [s2Get user_field="s2member_custom" /] # Custom String value for the current User. [s2Get user_field="s2member_subscr_id" /] # Paid Subscr. ID for the current User. [s2Get user_field="s2member_subscr_or_wp_id" /] # Paid Subscr. ID, else WordPress® User ID. [s2Get user_field="s2member_subscr_gateway" /] # Paid Subscr. Gateway Code for the current User. [s2Get user_field="s2member_registration_ip" /] # IP Address the current User had during registration. [s2Get user_field="s2member_access_role" /] # A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). [s2Get user_field="s2member_access_level" /] # An s2Member Membership Access Level number. [s2Get user_field="s2member_access_label" /] # An s2Member Membership Access Label ( i.e. Bronze, Gold, Silver, Platinum, or whatever is configured ). Pulling Data From Your Own Custom Fields ?php $my_field_data = get_user_field ( "my_field_id" ) ; # The Unique Field ID you configured with s2Member. ? Shortcode Equivalent [s2Get user_field="my_field_id" /] # The Unique Field ID you configured with s2Member. Pulling Data For A Particular User ID ?php $user_login = get_user_field ( "user_login" , 123 ) ; # Username for the User with ID #123. $user_email = get_user_field ( "user_email" , 123 ) ; # Email Address for the User with ID #123. $first_name = get_user_field ( "first_name" , 123 ) ; # First Name for the User with ID #123. $last_name = get_user_field ( "last_name" , 123 ) ; # Last Name for the User with ID #123. $full_name = get_user_field ( "full_name" , 123 ) ; # First and Last Name for the User with ID #123. $display_name = get_user_field ( "display_name" , 123 ) ; # Display Name for the User with ID #123. ? Shortcode Equivalents [s2Get user_field="user_login" user_id="123" /] # Username for the User with ID #123. [s2Get user_field="user_email" user_id="123" /] # Email Address for the User with ID #123. [s2Get user_field="first_name" user_id="123" /] # First Name for the User with ID #123. [s2Get user_field="last_name" user_id="123" /] # Last Name for the User with ID #123. [s2Get user_field="full_name" user_id="123" /] # First and Last Name for the User with ID #123. [s2Get user_field="display_name" user_id="123" /] # Display Name for the User with ID #123. Finding A User ID, Based On Username ?php $user = new WP_User ( "johndoe22" ) ; $user_id = $user - ID ; ? Finding A Username, Based On User ID ?php $user = new WP_User ( 123 ) ; $user_login = $user - user_login ; # Or you could just use this alternate method. $user_login = get_user_field ( "user_login" , 123 ) ; ? Alternative Using get_user_option ( ) Native To WordPress® Most of the s2Member fields are stored in the usermeta table ( a WordPress® standard ), so they could also be retrieved with WordPress® Function → get_user_option() if you prefer, which is already native to WordPress®. That being said, s2Member\API_Functions → get_user_field() is provided by s2Member as a way to retrieve almost anything. ?php $s2member_custom = get_user_option ( "s2member_custom" ) ; # Custom String value for the current User. $s2member_subscr_id = get_user_option ( "s2member_subscr_id" ) ; # Paid Subscr. ID for the current User. $s2member_subscr_gateway = get_user_option ( "s2member_subscr_gateway" ) ; # Paid Subscr. Gateway Code for the current User. $s2member_registration_ip = get_user_option ( "s2member_registration_ip" ) ; # IP the current User had during registration. $s2member_custom_fields = get_user_option ( "s2member_custom_fields" ) ; # Associative array of all Custom Registration Fields. $s2member_file_download_access_log = get_user_option ( "s2member_file_download_access_log" ) ; # Associative array of all File Downloads by the current User. $s2member_auto_eot_time = get_user_option ( "s2member_auto_eot_time" ) ; # Auto EOT-Time for the current User ( when applicable ). $s2member_last_payment_time = get_user_option ( "s2member_last_payment_time" ) ; # Timestamp. Last time an actual payment was received by s2Member. $s2member_paid_registration_times = get_user_option ( "s2member_paid_registration_times" ) ; # Timestamps. Associative array of all Paid Registration Times. ? Practical Shortcode Equivalents [s2Get user_option="s2member_custom" /] # Custom String value for the current User. [s2Get user_option="s2member_subscr_id" /] # Paid Subscr. ID for the current User. [s2Get user_option="s2member_subscr_gateway" /] # Paid Subscr. Gateway Code for the current User. [s2Get user_option="s2member_registration_ip" /] # IP the current User had during registration. Since: 3.5 Parameters: str $field_id - Required. A unique Custom Registration Field ID, that you configured with s2Member. Or, this could be set to any property that exists on the WP_User object for a particular User; ( i.e. id, ID, user_login, user_email, first_name, last_name, display_name, ip, IP, s2member_registration_ip, s2member_custom, s2member_subscr_id, s2member_subscr_or_wp_id, s2member_subscr_gateway, s2member_custom_fields, s2member_file_download_access_log, s2member_auto_eot_time, s2member_last_payment_time, s2member_paid_registration_times, s2member_access_role, s2member_access_level, s2member_access_label, s2member_access_ccaps, etc, etc. ). int $user_id - Optional. Defaults to the current User's ID. Returns: mixed - The value of the requested field, or false if the field does not exist. See Also: s2Member\API_Functions → s2member_registration_time() s2Member\API_Functions → s2member_paid_registration_time() WordPress® Function → get_user_option() WordPress® Function → update_user_option() WordPress® Function → wp_get_current_user() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1121 is_category_permitted_by_s2member() public bool is_category_permitted_by_s2member (int $cat_id) Conditional to determine if a specific Category is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_category_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_category_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $cat_id ( int Required ). This should be a WordPress® Category ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_category_permitted_by_s2member( 123 ) ) echo 'Category ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_category_permitted_by_s2member(123)] Category ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $cat_id - Required. This should be a WordPress® Category ID. Returns: bool - True if the current User IS permitted, else false if the Category is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1053 is_category_protected_by_s2member() public array|bool is_category_protected_by_s2member (int $cat_id, bool $check_user) Conditional to determine if a specific Category is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $cat_id ( int Required ). This should be a WordPress® Category ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Category is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_category_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_category_protected_by_s2member( 123 ) ) echo 'Category ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_category_protected_by_s2member(123)] Category ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $cat_id - Required. This should be a WordPress® Category ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Category is not protected ( i.e. available publicly ). When/if the Category IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Category. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1576 is_page_permitted_by_s2member() public bool is_page_permitted_by_s2member (int $page_id) Conditional to determine if a specific Page is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_page_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_page_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $page_id ( int Required ). This should be a WordPress® Page ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_page_permitted_by_s2member( 123 ) ) echo 'Page ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_page_permitted_by_s2member(123)] Page ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $page_id - Required. This should be a WordPress® Page ID. Returns: bool - True if the current User IS permitted, else false if the Page is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1508 is_page_protected_by_s2member() public array|bool is_page_protected_by_s2member (int $page_id, bool $check_user) Conditional to determine if a specific Page is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $page_id ( int Required ). This should be a WordPress® Page ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Page is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_page_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_page_protected_by_s2member( 123 ) ) echo 'Page ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_page_protected_by_s2member(123)] Page ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $page_id - Required. This should be a WordPress® Page ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Page is not protected ( i.e. available publicly ). When/if the Page IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Page. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #961 is_permitted_by_s2member() public bool is_permitted_by_s2member (int|str $what, str $type) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $what ( int|str Optional ). Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. If you pass in an ID, s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. If you pass in a URL or URI, s2Member will ONLY check URI Restrictions, because it has no ID to work with. This is useful though. Some protected content is not associated with an ID. In those cases, URI Restrictions are all the matter. Note: when passing in a URL or URI, the $type parameter must be set to URI or uri. Case insensitive. Parameter $type ( str Optional ). One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Code Sample Using Function Parameters ?php if (is_permitted_by_s2member( 123 ) ) echo 'Post or Page ID #123 is permitted by s2Member.' ; else if (is_permitted_by_s2member( 332 , "tag" ) ) echo 'Tag ID #332 is permitted by s2Member.' ; else if (is_permitted_by_s2member( 554 , "category" ) ) echo 'Category ID #554 is permitted by s2Member.' ; else if (is_permitted_by_s2member( "http://example.com/members/" , "uri" ) ) echo 'This URL is permitted by s2Member.' ; else if (is_permitted_by_s2member( "/members/" , "uri" ) ) echo 'This URI is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_permitted_by_s2member(123)] Post or Page ID #123 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(332, tag)] Tag ID #332 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(554, category)] Category ID #554 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(http://example.com/members/, uri)] This URL is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(/members/, uri)] This URI is permitted by s2Member. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $what - Optional. Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. str $type - Optional. One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Returns: bool - True if the current User IS permitted, else false if the content is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1433 is_post_permitted_by_s2member() public bool is_post_permitted_by_s2member (int $post_id) Conditional to determine if a specific Post or Custom Post Type is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_post_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_post_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $post_id ( int Required ). This should be a WordPress® Post ID, or a Custom Post Type ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_post_permitted_by_s2member( 123 ) ) echo 'Post ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_post_permitted_by_s2member(123)] Post ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID. Returns: bool - True if the current User IS permitted, else false if the Post is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1365 is_post_protected_by_s2member() public array|bool is_post_protected_by_s2member (int $post_id, bool $check_user) Conditional to determine if a specific Post ( or Custom Post Type ) is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $post_id ( int Required ). This should be a WordPress® Post ID, or a Custom Post Type ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Post is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_post_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_post_protected_by_s2member( 123 ) ) echo 'Post ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_post_protected_by_s2member(123)] Post ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Post is not protected ( i.e. available publicly ). When/if the Post IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Post. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #839 is_protected_by_s2member() public array|bool is_protected_by_s2member (int|str $what, str $type, bool $check_user) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $what ( int|str Optional ). Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. If you pass in an ID, s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. If you pass in a URL or URI, s2Member will ONLY check URI Restrictions, because it has no ID to work with. This is useful though. Some protected content is not associated with an ID. In those cases, URI Restrictions are all the matter. Note: when passing in a URL or URI, the $type parameter must be set to URI or uri. Case insensitive. Parameter $type ( str Optional ). One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the content is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_protected_by_s2member( 123 ) ) echo 'Post or Page ID #123 is protected by s2Member.' ; else if (is_protected_by_s2member( 332 , "tag" ) ) echo 'Tag ID #332 is protected by s2Member.' ; else if (is_protected_by_s2member( 554 , "category" ) ) echo 'Category ID #554 is protected by s2Member.' ; else if (is_protected_by_s2member( "http://example.com/members/" , "uri" ) ) echo 'This URL is protected by URI Restrictions.' ; else if (is_protected_by_s2member( "/members/" , "uri" ) ) echo 'This URI is protected by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_protected_by_s2member(123)] Post or Page ID #123 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(332, tag)] Tag ID #332 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(554, category)] Category ID #554 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(http://example.com/members/, uri)] This URL is protected by URI Restrictions. [/s2If] [s2If is_protected_by_s2member(/members/, uri)] This URI is protected by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $what - Optional. Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. str $type - Optional. One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the content is not protected ( i.e. available publicly ). When/if content IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the content. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1290 is_tag_permitted_by_s2member() public bool is_tag_permitted_by_s2member (int|str $tag_id_slug_or_name) Conditional to determine if a specific Tag is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_tag_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_tag_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $tag_id_slug_or_name ( int|str Required ). This should be a WordPress® Tag ID, Tag Slug, or Tag Name. s2Member will check everything, including your configured URI Restrictions against the ID, or Slug, or Name. In other words, s2Member is capable of determining a URI based on the ID, or Slug, or Name that you pass in. So using an ID, or Slug, or Name results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_tag_permitted_by_s2member( 123 ) ) echo 'Tag ID #123 is permitted by s2Member.' ; else if (is_tag_permitted_by_s2member( "members-only" ) ) echo 'Tag Slug (members-only) is permitted by s2Member.' ; else if (is_tag_permitted_by_s2member( "Members Only" ) ) echo 'Tag Name (Members Only) is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_tag_permitted_by_s2member(123)] Tag ID #123 is permitted by s2Member. [/s2If] [s2If is_tag_permitted_by_s2member(members-only)] Tag Slug (members-only) is permitted by s2Member. [/s2If] NOTE: It's NOT possible to check a Tag Named "Members Only" with [s2If /], because Shortcode Conditionals may NOT contain spaces in their argument values. If you're using [s2If /] to check a Tag, please use the Slug or ID instead. *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name. Returns: bool - True if the current User IS permitted, else false if the Tag is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1209 is_tag_protected_by_s2member() public array|bool is_tag_protected_by_s2member (int|str $tag_id_slug_or_name, bool $check_user) Conditional to determine if a specific Tag is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $tag_id_slug_or_name ( int|str Required ). This should be a WordPress® Tag ID, Tag Slug, or Tag Name. s2Member will check everything, including your configured URI Restrictions against the ID, Slug, or Name. In other words, s2Member is capable of determining a URI based on the ID, or Slug, or Name that you pass in. So using an ID, or Slug, or Name results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Tag is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_tag_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_tag_protected_by_s2member( 123 ) ) echo 'Tag ID #123 is protected by s2Member.' ; else if (is_tag_protected_by_s2member( "members-only" ) ) echo 'Tag Slug (members-only) is protected by s2Member.' ; else if (is_tag_protected_by_s2member( "Members Only" ) ) echo 'Tag Name (Members Only) is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_tag_protected_by_s2member(123)] Tag ID #123 is protected by s2Member. [/s2If] [s2If is_tag_protected_by_s2member(members-only)] Tag Slug (members-only) is protected by s2Member. [/s2If] NOTE: It's NOT possible to check a Tag Named "Members Only" with [s2If /], because Shortcode Conditionals may NOT contain spaces in their argument values. If you're using [s2If /] to check a Tag, please use the Slug or ID instead. *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Tag is not protected ( i.e. available publicly ). When/if the Tag IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Tag. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1733 is_uri_permitted_by_s2member() public bool is_uri_permitted_by_s2member (str $uri_or_full_url) Conditional to determine if a specific URI or URL is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_uri_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_uri_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $uri_or_full_url ( str Required ). This should be a URI starting with /, or a full URL is also fine. Important Notes About This Function This function will ONLY test against URI Restrictions you've configured with s2Member. If you need an all-inclusive test, please use s2Member\API_Functions → is_permitted_by_s2member() with an ID. Code Sample Using Function Parameters ?php if (is_uri_permitted_by_s2member( "/members-only/sub-section" ) ) echo 'The URI (/members-only/sub-section) is permitted by URI Restrictions.' ; else if (is_uri_permitted_by_s2member( "http://example.com/members-only/sub-section" ) ) echo 'The URL (http://example.com/members-only/sub-section) is permitted by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_uri_permitted_by_s2member(/members-only/sub-section)] The URI (/members-only/sub-section) is permitted by URI Restrictions. [/s2If] [s2If is_uri_permitted_by_s2member(http://example.com/members-only/sub-section)] The URL (http://example.com/members-only/sub-section) is permitted by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: str $uri_or_full_url - Required. This should be a URI starting with /, or a full URL is also fine. Returns: bool - True if the current User IS permitted, else false if the URI or URL is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1658 is_uri_protected_by_s2member() public array|bool is_uri_protected_by_s2member (str $uri_or_full_url, bool $check_user) Conditional to determine if a specific URI or URL is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $uri_or_full_url ( str Required ). This should be a URI starting with /, or a full URL is also fine. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the URI or URL is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_uri_permitted_by_s2member(). Important Notes About This Function This function will ONLY test against URI Restrictions you've configured with s2Member. If you need an all-inclusive test, please use s2Member\API_Functions → is_protected_by_s2member() with an ID. Code Sample Using Function Parameters ?php if (is_uri_protected_by_s2member( "/members-only/sub-section" ) ) echo 'The URI (/members-only/sub-section) is protected by URI Restrictions.' ; else if (is_uri_protected_by_s2member( "http://example.com/members-only/sub-section" ) ) echo 'The URL (http://example.com/members-only/sub-section) is protected by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_uri_protected_by_s2member(/members-only/sub-section)] The URI (/members-only/sub-section) is protected by URI Restrictions. [/s2If] [s2If is_uri_protected_by_s2member(http://example.com/members-only/sub-section)] The URL (http://example.com/members-only/sub-section) is protected by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: str $uri_or_full_url - Required. This should be a URI starting with /, or a full URL is also fine. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the URI or URL is not protected ( i.e. available publicly ). When/if the URI or URL IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the URI or URL. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #54 is_user_not_logged_in() public bool is_user_not_logged_in () Conditional to determine if the current User is NOT logged in. Counterpart WordPress® Function → is_user_logged_in() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( is_user_logged_in ( ) ) echo 'You ARE logged in.' ; else if (is_user_not_logged_in( ) ) echo 'You are NOT logged in.' ; ? Shortcode Conditional Equivalent [s2If is_user_logged_in()] You ARE logged in. [/s2If] [s2If is_user_not_logged_in()] You are NOT logged in. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Returns: bool - True if the current User is NOT logged in, else false. See Also: WordPress® Function → is_user_logged_in() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1879 s2member_file_download_key() public str s2member_file_download_key (str $file, str|bool $directive) Generates a File Download Key that provides access to a File protected by s2Member. By default, s2Member uses your Basic Download Restrictions. For more information on this, please check your Dashboard under: s2Member - Download Options - Basic Download Restrictions. Advanced Download Restrictions Or, you can also force s2Member to allow File Downloads, using an extra query string parameter s2member_file_download_key. A File Download Key is passed through this parameter; it tells s2Member to allow the download of this particular file, regardless of Membership Level; and WITHOUT checking any Basic Restrictions, that you may, or may not, have configured. Code Sample Using A Download Key a href="/?s2member_file_download=file.zip&s2member_file_download_key=?php echo s2member_file_download_key( "file.zip" ) ; ?"Download Now/a Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). This API Funtion produces a time-sensitive File Download Key that is unique to each and every visitor. Each Key it produces ( at the time it is produced ), will be valid for the current day, and only for a specific IP address and User-Agent string; as detected by s2Member. This makes it possible for you to create links on your site, which provide access to protected File Downloads; without having to worry about one visitor sharing their link with another. When /?s2member_file_download_key = a valid Key generated by this function, it works independently from Member Level Access. That is, a visitor does NOT have to be logged in to receive access; they just need a valid Key. Using this advanced technique, you could extend s2Member's file protection routines, or even combine them with Specific Post/Page Access, and more. The possibilities are limitless really. Since: 3.5 Parameters: str $file - Location of the protected File, relative to the /s2member-files/ directory. str|bool $directive - Optional. Defaults to false. If you set this to any non-zero value ( i.e. the string universal ), the resulting Key will be universal ( i.e. valid for any User, at any time, from any browser ). That is to say; universal, for this particular File. It is also possible to pass in the $directive string ip-forever, making the Key last forever, but only for a specific IP address. Returns: str - The File Download Key. Which is an MD5 hash ( always 32 characters ), URL-safe. Todo: Create a Shortcode equivalent. Allow custom expiration times. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1963 s2member_paid_registration_time() public int s2member_paid_registration_time (str $level, int $user_id) Retrieves a Paid Registration Time for the current User, and/or for a particular User. NOTE A Paid Registration Time, is NOT necessarily related specifically to a Payment. s2Member records a Paid Registration Time, anytime a User acquires paid Membership Level Access. In other words, if you create a new User inside your Dashboard at a Membership Level greater than Level #0, s2Member will record a Paid Registration Time immediately, because Membership Levels 0, are reserved for paying Members. s2Member monitors changes to all User accounts, and records the first Paid Registration Time for each Member, at each paid Membership Level. So, s2Member stores the first Time a Member reaches each Level of paid access; and s2Member does NOT care if they actually paid, or not. Code Sample Using Function Parameters ?php $time = s2member_registration_time ( ) ; # first registration time ( free or otherwise ). $time = s2member_paid_registration_time ( ) ; # first "paid" registration and/or upgrade time. $time = s2member_paid_registration_time ( "level1" ) ; # first "paid" registration or upgrade time at Level#1. $time = s2member_paid_registration_time ( "level2" ) ; # first "paid" registration or upgrade time at Level#2. $time = s2member_paid_registration_time ( "level3" ) ; # first "paid" registration or upgrade time at Level#3. $time = s2member_paid_registration_time ( "level4" ) ; # first "paid" registration or upgrade time at Level#4. ? Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). Since: 3.5 Parameters: str $level - Optional. Defaults to the first/initial Paid Registration Time, regardless of Level#. int $user_id - Optional. Defaults to the current User's ID. Returns: int - A Unix Timestamp. See Also: s2Member\API_Functions → get_user_field() Todo: Create a Shortcode equivalent. [ back to top ] s2member-pro\includes\functions\separates\gateways\authnet\authnet-api-functions.inc.php at line #50 s2member_pro_authnet_s2p_v_query_ok() public bool s2member_pro_authnet_s2p_v_query_ok (str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. This can be used for verifying the integrity of variables in a success query string. Example usage: if (s2member_pro_authnet_s2p_v_query_ok( $_SERVER [ "QUERY_STRING" ] ) ) { } Since: 1.5 Parameters: str $qs - Optional. Defaults to $_SERVER [ "QUERY_STRING" ] . book $ignore_timestamp - Optional. If true, timestamp is ignored. Defaults to false. Returns: bool - True if the query string is OK/verified, else false. [ back to top ] s2member-pro\includes\functions\api-functions.inc.php at line #104 s2member_pro_login_widget() public str s2member_pro_login_widget (array $options, array $args) Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file. This function will return the HTML output from the widget function call. Example usage: ?php echo s2member_pro_login_widget( ) ; ? The $options parameter (array) is completely optional ( i.e. NOT required ). It can be passed in as an array of options; overriding some or all of these defaults: "title" = "Membership Login" Title when NOT logged in, or leave this blank if you'd prefer not to show a title. "signup_url" = "%%automatic%%" Full Signup URL, or use %%automatic%% for the Membership Options Page. If you leave this blank, it will not be shown. "login_redirect" = "" Empty ( i.e. "" ) = Login Welcome Page, %%previous%% = Previous Page, %%home%% = Home Page, or use a full URL of your own. "logged_out_code" = "" HTML/PHP code to display when logged out. May also contain WP Shortcodes if you like. "profile_title" = "My Profile Summary" Title when a User is logged in. Or you can leave this blank if you'd prefer not to show a title. "display_gravatar" = "1" Display Gravatar image when logged in? 1 = yes, 0 = no. Gravatars are based on email address. "link_gravatar" = "1" Link Gravatar image to Gravatar.com? 1 = yes, 0 = no. Allows Users to setup a Gravatar. "display_name" = "1" Display the current User's WordPress® "Display Name" when logged in? 1 = yes, 0 = no. "logged_in_code" = "" HTML/PHP code to display when logged in. May also contain WP Shortcodes if you like. "logout_redirect" = "%%home%%" Empty ( i.e. "" ) = Login Screen, %%previous%% = Previous Page, %%home%% = Home Page, or use a full URL of your own. "my_account_url" = "%%automatic%%" Full URL of your own, or use %%automatic%% for the Login Welcome Page. Leave empty to not show this at all. "my_profile_url" = "%%automatic%%" Full URL of your own, or use %%automatic%% for a JavaScript popup. Leave empty to not show this at all. The $args parameter (array) is also completely optional ( i.e. NOT required ). It can be passed in as an array of options: overriding some or all of these defaults: "before_widget" = "" HTML code to display before the widget. "before_title" = "h3" HTML code to display before the title. "after_title" = "/h3" HTML code to display after the title. "after_widget" = "" HTML code to display after the widget. Since: 1.5 Parameters: array $options - Optional. See function description for details. array $args - Optional. See function description for details. Returns: str - The Pro Login Widget, HTML markup. [ back to top ] s2member-pro\includes\functions\separates\gateways\paypal\paypal-api-functions.inc.php at line #50 s2member_pro_paypal_s2p_v_query_ok() public bool s2member_pro_paypal_s2p_v_query_ok (str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. This can be used for verifying the integrity of variables in a success query string. Example usage: if (s2member_pro_paypal_s2p_v_query_ok( $_SERVER [ "QUERY_STRING" ] ) ) { } Since: 1.5 Parameters: str $qs - Optional. Defaults to $_SERVER [ "QUERY_STRING" ] . book $ignore_timestamp - Optional. If true, timestamp is ignored. Defaults to false. Returns: bool - True if the query string is OK/verified, else false. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1918 s2member_registration_time() public int s2member_registration_time (int $user_id) Obtains the Registration Time for the current User, and/or for a particular User. The Registration Time, is the time at which the Username was created for the account, that's it. There's nothing special about this. This simply returns a Unix Timestamp. Code Sample Using Function Parameters ?php if (s2member_registration_time( ) = strtotime ( "-30 days" ) ) echo 'The current User has existed for at least 30 days.' ; else if (s2member_registration_time( 123 ) = strtotime ( "-30 days" ) ) echo 'User with ID #123 has existed for at least 30 days.' ; ? Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). Since: 3.5 Parameters: int $user_id - Optional. Defaults to the current User's ID. Returns: int - A Unix Timestamp. The Registration Time, is the time at which the Username was created for the account, that's it. See Also: s2Member\API_Functions → get_user_field() Todo: Create a Shortcode equivalent. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #591 user_cannot() public bool user_cannot (int|str $id, str $capability) Conditional to determine if a specific User does NOT have a specific Capability or Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (user_can( 123 , "access_s2member_level0" ) ) echo 'User ID# 123 CAN access content protected at Level #0.' ; else if (user_cannot( 123 , "access_s2member_level0" ) ) echo 'User ID# 123 CANNOT access content at Level #0.' ; ? Shortcode Conditional Equivalent [s2If user_can(123, access_s2member_level0)] User ID# 123 CAN access content protected at Level #0. [/s2If] [s2If user_cannot(123, access_s2member_level0)] User ID# 123 CANNOT access content at Level #0. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $id - A numeric WordPress® User ID. str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Returns: bool - True if the specific User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #132 user_is() public bool user_is (int|str $id, str $role) Conditional to determine if a specific User is/has a specific Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (user_is( 123 , "subscriber" ) ) echo 'User ID# 123 is a Free Subscriber at Level #0.' ; else if (user_is( 123 , "s2member_level1" ) ) echo 'User ID# 123 is a Member at Level #1.' ; else if (user_can( 123 , "access_s2member_level2" ) ) echo 'User ID# 123 has access to content protected at Level #2.' ; # But, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If user_is(123, subscriber)] User ID# 123 is a Free Subscriber at Level #0. [/s2If] [s2If user_is(123, s2member_level1)] User ID# 123 is a Member at Level #1. [/s2If] [s2If user_can(123, access_s2member_level2)] User ID# 123 has access to content protected at Level #2. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 110524RC Parameters: int|str $id - A numeric WordPress® User ID. str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the specific User is/has the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #210 user_is_not() public bool user_is_not (int|str $id, str $role) Conditional to determine if a specific User is/does NOT have a specific Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (user_is( 123 , "subscriber" ) ) echo 'User ID# 123 is a Free Subscriber at Level #0.' ; else if (user_is( 123 , "s2member_level1" ) ) echo 'User ID# 123 is a Member at Level #1.' ; else if (user_can( 123 , "access_s2member_level2" ) && user_is_not( 123 , "s2member_level2" ) ) echo 'User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member.' ; # So, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If user_is(123, subscriber)] User ID# 123 is a Free Subscriber at Level #0. [/s2If] [s2If user_is(123, s2member_level1)] User ID# 123 is a Member at Level #1. [/s2If] [s2If user_can(123, access_s2member_level2) AND user_is_not(123, s2member_level2)] User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 110524RC Parameters: int|str $id - A numeric WordPress® User ID. str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the specific User is/does NOT have the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Summary Functions Hooks/Filters Function Summary | Function Detail(!-- :: s-words --)

Statistics: Posted by System Robot — July 11th, 2011, 5:07 pm


]]>
2011-07-11T14:58:20-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=26498#p26498 <![CDATA[s2Member v110710 / Package s2Member\API_Fu...]]>
s2Member v110710
Package s2Member\API_Functions ( Functions )
Docs updated: July 11, 2011, 3:58 pm

Open for public discussion.
(!-- s-words :: --)Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Summary Functions Hooks/Filters Function Summary | Function Detail Package s2Member\API_Functions ( 31 Functions ) ( 31 Functions )Function Summary public null attach_s2member_query_filters() Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. public bool current_user_cannot(str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role. public bool current_user_cannot_for_blog(int|str $blog_id, str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network. public bool current_user_is(str $role) Conditional to determine if the current User is/has a specific Role. public bool current_user_is_for_blog(int|str $blog_id, str $role) Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network. public bool current_user_is_not(str $role) Conditional to determine if the current User is/does NOT have a specific Role. public bool current_user_is_not_for_blog(int|str $blog_id, str $role) Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network. public null detach_s2member_query_filters() Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. public mixed get_user_field(str $field_id, int $user_id) A powerful function that can retrieve almost anything you need to know about the current User, and/or a particular User. public bool is_category_permitted_by_s2member(int $cat_id) Conditional to determine if a specific Category is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_category_protected_by_s2member(int $cat_id, bool $check_user) Conditional to determine if a specific Category is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_page_permitted_by_s2member(int $page_id) Conditional to determine if a specific Page is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_page_protected_by_s2member(int $page_id, bool $check_user) Conditional to determine if a specific Page is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_permitted_by_s2member(int|str $what, str $type) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public bool is_post_permitted_by_s2member(int $post_id) Conditional to determine if a specific Post or Custom Post Type is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_post_protected_by_s2member(int $post_id, bool $check_user) Conditional to determine if a specific Post ( or Custom Post Type ) is protected by s2Member; without considering the current User's Role/Capabilites. public array|bool is_protected_by_s2member(int|str $what, str $type, bool $check_user) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_tag_permitted_by_s2member(int|str $tag_id_slug_or_name) Conditional to determine if a specific Tag is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_tag_protected_by_s2member(int|str $tag_id_slug_or_name, bool $check_user) Conditional to determine if a specific Tag is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_uri_permitted_by_s2member(str $uri_or_full_url) Conditional to determine if a specific URI or URL is permitted by s2Member, with consideration given to the current User's Role/Capabilites. public array|bool is_uri_protected_by_s2member(str $uri_or_full_url, bool $check_user) Conditional to determine if a specific URI or URL is protected by s2Member; without considering the current User's Role/Capabilites. public bool is_user_not_logged_in() Conditional to determine if the current User is NOT logged in. public str s2member_file_download_key(str $file, str|bool $directive) Generates a File Download Key that provides access to a File protected by s2Member. public int s2member_paid_registration_time(str $level, int $user_id) Retrieves a Paid Registration Time for the current User, and/or for a particular User. public bool s2member_pro_authnet_s2p_v_query_ok(str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. public str s2member_pro_login_widget(array $options, array $args) Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file. public bool s2member_pro_paypal_s2p_v_query_ok(str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. public int s2member_registration_time(int $user_id) Obtains the Registration Time for the current User, and/or for a particular User. public bool user_cannot(int|str $id, str $capability) Conditional to determine if a specific User does NOT have a specific Capability or Role. public bool user_is(int|str $id, str $role) Conditional to determine if a specific User is/has a specific Role. public bool user_is_not(int|str $id, str $role) Conditional to determine if a specific User is/does NOT have a specific Role. ( 31 Functions )Function Detail s2member\includes\functions\api-functions.inc.php at line #1781 attach_s2member_query_filters() public null attach_s2member_query_filters () Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. This functionality is already built right into s2Member's UI configuration panels, but in cases where a plugin/theme developer needs more control, this may come in handy. In the UI configuration for s2Member, please see: Alternative View Protection. Code Sample Using s2Member's Query Filters ?php attach_s2member_query_filters( ) ; query_posts ( "posts_per_page=5" ) ; if ( have_posts ( ) ) : while ( have_posts ( ) ) : the_post ( ) ; # Protected content will be excluded automatically. # ( based on the current User's Role/Capabilities ) endwhile ; endif ; wp_reset_query ( ) ; detach_s2member_query_filters( ) ; ? Shortcode Equivalent There is NO Shortcode equivalent for this. Since: 3.5 Returns: null See Also: s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #660 current_user_cannot() public bool current_user_cannot (str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( current_user_can ( "access_s2member_level0" ) ) echo 'You CAN access content protected at Level #0.' ; else if (current_user_cannot( "access_s2member_level0" ) ) echo 'You CANNOT access content protected at Level #0.' ; ? Shortcode Conditional Equivalent [s2If current_user_can(access_s2member_level0)] You CAN access content protected at Level #0. [/s2If] [s2If current_user_cannot(access_s2member_level0)] You CANNOT access content protected at Level #0. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Or a Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #730 current_user_cannot_for_blog() public bool current_user_cannot_for_blog (int|str $blog_id, str $capability) Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( current_user_can_for_blog ( 5 , "access_s2member_level0" ) ) echo 'You CAN access content protected at Level #0 ( on Blog ID 5 ).' ; else if (current_user_cannot_for_blog( 5 , "access_s2member_level0" ) ) echo 'You CANNOT access content protected at Level #0 ( on Blog ID 5 ).' ; ? Shortcode Conditional Equivalent [s2If current_user_can_for_blog(5, access_s2member_level0)] You CAN access content protected at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_cannot_for_blog(5, access_s2member_level0)] You CANNOT access content protected at Level #0 ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Or a Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #288 current_user_is() public bool current_user_is (str $role) Conditional to determine if the current User is/has a specific Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0.' ; else if (current_user_is( "s2member_level1" ) ) echo 'You ARE a Member at Level #1.' ; else if ( current_user_can ( "access_s2member_level2" ) ) echo 'You DO have access to content protected at Level #2.' ; # But, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If curent_user_is(subscriber)] You ARE a Free Subscriber at Level #0. [/s2If] [s2If curent_user_is(s2member_level1)] You ARE a Member at Level #1. [/s2If] [s2If current_user_can(access_s2member_level2)] You DO have access to content protected at Level #2. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/has the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #449 current_user_is_for_blog() public bool current_user_is_for_blog (int|str $blog_id, str $role) Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on this Blog ).' ; else if (current_user_is_for_blog( 5 , "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ).' ; else if (current_user_is_for_blog( 5 , "s2member_level1" ) ) echo 'You ARE a Member at Level #1 ( on Blog ID 5 ).' ; else if ( current_user_can_for_blog ( 5 , "access_s2member_level2" ) ) echo 'You DO have access to content protected at Level #2 ( on Blog ID 5 ).' ; # But, (important) they could actually be a Level #3 or #4 Member ( on Blog ID 5 ); # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is(subscriber)] You ARE a Free Subscriber at Level #0 ( on this Blog ). [/s2If] [s2If current_user_is_for_blog(5, subscriber)] You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_is_for_blog(5, s2member_level1)] You ARE a Member at Level #1 ( on Blog ID 5 ). [/s2If] [s2If current_user_can_for_blog(5, access_s2member_level2)] You DO have access to content protected at Level #2 ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/has the specified Role, on the specified Blog, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #365 current_user_is_not() public bool current_user_is_not (str $role) Conditional to determine if the current User is/does NOT have a specific Role. Another function WordPress® Function → current_user_can() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is( "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0.' ; else if (current_user_is( "s2member_level1" ) ) echo 'You ARE a Member at Level #1.' ; else if ( current_user_can ( "access_s2member_level2" ) && current_user_is_not( "s2member_level2" ) ) echo 'You DO have access to content protected at Level #2, but you are NOT a Level #2 Member.' ; # So, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is(subscriber)] You ARE a Free Subscriber at Level #0. [/s2If] [s2If current_user_is(s2member_level1)] You ARE a Member at Level #1. [/s2If] [s2If current_user_can(access_s2member_level2) AND current_user_is_not(s2member_level2)] You DO have access to content protected at Level #2, but you are NOT a Level #2 Member. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/does NOT have the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #521 current_user_is_not_for_blog() public bool current_user_is_not_for_blog (int|str $blog_id, str $role) Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network. Another function WordPress® Function → current_user_can_for_blog() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (current_user_is_for_blog( 5 , "subscriber" ) ) echo 'You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ).' ; else if ( current_user_can_for_blog ( 5 , "access_s2member_level1" ) && current_user_is_not_for_blog( 5 , "s2member_level1" ) ) echo 'You DO have access to content protected at Level #1 ( on Blog ID 5 ), but you are NOT a Level #1 Member ( on Blog ID 5 ).' ; # So, (important) they could actually be a Level #2 or #3 or #4 Member ( on Blog ID 5 ); # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If current_user_is_for_blog(5, subscriber)] You ARE a Free Subscriber at Level #0 ( on Blog ID 5 ). [/s2If] [s2If current_user_can_for_blog(5, access_s2member_level1) AND current_user_is_not_for_blog(5, s2member_level1)] You DO have access to content protected at Level #1 ( on Blog ID 5 ), but you are NOT a Level #1 Member ( on Blog ID 5 ). [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $blog_id - A WordPress® Blog ID ( must be numeric ). str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the current User is/does NOT have the specified Role, on the specified Blog, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1827 detach_s2member_query_filters() public null detach_s2member_query_filters () Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content ( i.e content NOT available to the current User ), is excluded automatically. This functionality is already built right into s2Member's UI configuration panels, but in cases where a plugin/theme developer needs more control, this may come in handy. In the UI configuration for s2Member, please see: Alternative View Protection. Code Sample Using s2Member's Query Filters ?php attach_s2member_query_filters( ) ; query_posts ( "posts_per_page=5" ) ; if ( have_posts ( ) ) : while ( have_posts ( ) ) : the_post ( ) ; # Protected content will be excluded automatically. # ( based on the current User's Role/Capabilities ) endwhile ; endif ; wp_reset_query ( ) ; detach_s2member_query_filters( ) ; ? Shortcode Equivalent There is NO Shortcode equivalent for this. Since: 3.5 Returns: null See Also: s2Member\API_Functions → attach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #2124 get_user_field() public mixed get_user_field (str $field_id, int $user_id) A powerful function that can retrieve almost anything you need to know about the current User, and/or a particular User. Scans all properties of the WP_User object. It defaults to the current User, but can also be used to obtain information about a particular User, by passing in a specific User ID. It can be used to retrieve basic information like first_name, last_name, user_email, user_login. It can also be used to retrieve User Meta/Options, Role/Capabilities, and even supports Custom Registration Fields configured with s2Member and many other plugins. Here Are A Few Examples ?php $user_login = get_user_field ( "user_login" ) ; # Username for the current User. $user_email = get_user_field ( "user_email" ) ; # Email Address for the current User. $first_name = get_user_field ( "first_name" ) ; # First Name for the current User. $last_name = get_user_field ( "last_name" ) ; # Last Name for the current User. $full_name = get_user_field ( "full_name" ) ; # First and Last Name for the current User. $display_name = get_user_field ( "display_name" ) ; # Display Name for the current User. ? Shortcode Equivalents [s2Get user_field="user_login" /] # Username for the current User. [s2Get user_field="user_email" /] # Email Address for the current User. [s2Get user_field="first_name" /] # First Name for the current User. [s2Get user_field="last_name" /] # Last Name for the current User. [s2Get user_field="full_name" /] # First and Last Name for the current User. [s2Get user_field="display_name" /] # Display Name for the current User. More Examples With s2Member Fields ?php $s2member_custom = get_user_field ( "s2member_custom" ) ; # Custom String value for the current User. $s2member_subscr_id = get_user_field ( "s2member_subscr_id" ) ; # Paid Subscr. ID for the current User. $s2member_subscr_or_wp_id = get_user_field ( "s2member_subscr_or_wp_id" ) ; # Paid Subscr. ID, else WordPress® User ID. $s2member_subscr_gateway = get_user_field ( "s2member_subscr_gateway" ) ; # Paid Subscr. Gateway Code for the current User. $s2member_registration_ip = get_user_field ( "s2member_registration_ip" ) ; # IP the current User had during registration. $s2member_custom_fields = get_user_field ( "s2member_custom_fields" ) ; # Associative array of all Custom Registration Fields. $s2member_file_download_access_log = get_user_field ( "s2member_file_download_access_log" ) ; # Associative array of all File Downloads by the current User. $s2member_auto_eot_time = get_user_field ( "s2member_auto_eot_time" ) ; # Auto EOT-Time for the current User ( when applicable ). $s2member_last_payment_time = get_user_field ( "s2member_last_payment_time" ) ; # Timestamp. Last time an actual payment was received by s2Member. $s2member_paid_registration_times = get_user_field ( "s2member_paid_registration_times" ) ; # Timestamps. Associative array of all Paid Registration Times. $s2member_access_role = get_user_field ( "s2member_access_role" ) ; # A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). $s2member_access_level = get_user_field ( "s2member_access_level" ) ; # An s2Member Membership Access Level number. $s2member_access_label = get_user_field ( "s2member_access_label" ) ; # An s2Member Membership Access Label ( i.e. Bronze, Gold, Silver, Platinum, or whatever is configured ). $s2member_access_ccaps = get_user_field ( "s2member_access_ccaps" ) ; # An array of Custom Capabilities the current User has ( i.e. music,videos ). ? Practical Shortcode Equivalents [s2Get user_field="s2member_custom" /] # Custom String value for the current User. [s2Get user_field="s2member_subscr_id" /] # Paid Subscr. ID for the current User. [s2Get user_field="s2member_subscr_or_wp_id" /] # Paid Subscr. ID, else WordPress® User ID. [s2Get user_field="s2member_subscr_gateway" /] # Paid Subscr. Gateway Code for the current User. [s2Get user_field="s2member_registration_ip" /] # IP Address the current User had during registration. [s2Get user_field="s2member_access_role" /] # A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). [s2Get user_field="s2member_access_level" /] # An s2Member Membership Access Level number. [s2Get user_field="s2member_access_label" /] # An s2Member Membership Access Label ( i.e. Bronze, Gold, Silver, Platinum, or whatever is configured ). Pulling Data From Your Own Custom Fields ?php $my_field_data = get_user_field ( "my_field_id" ) ; # The Unique Field ID you configured with s2Member. ? Shortcode Equivalent [s2Get user_field="my_field_id" /] # The Unique Field ID you configured with s2Member. Pulling Data For A Particular User ID ?php $user_login = get_user_field ( "user_login" , 123 ) ; # Username for the User with ID #123. $user_email = get_user_field ( "user_email" , 123 ) ; # Email Address for the User with ID #123. $first_name = get_user_field ( "first_name" , 123 ) ; # First Name for the User with ID #123. $last_name = get_user_field ( "last_name" , 123 ) ; # Last Name for the User with ID #123. $full_name = get_user_field ( "full_name" , 123 ) ; # First and Last Name for the User with ID #123. $display_name = get_user_field ( "display_name" , 123 ) ; # Display Name for the User with ID #123. ? Shortcode Equivalents [s2Get user_field="user_login" user_id="123" /] # Username for the User with ID #123. [s2Get user_field="user_email" user_id="123" /] # Email Address for the User with ID #123. [s2Get user_field="first_name" user_id="123" /] # First Name for the User with ID #123. [s2Get user_field="last_name" user_id="123" /] # Last Name for the User with ID #123. [s2Get user_field="full_name" user_id="123" /] # First and Last Name for the User with ID #123. [s2Get user_field="display_name" user_id="123" /] # Display Name for the User with ID #123. Finding A User ID, Based On Username ?php $user = new WP_User ( "johndoe22" ) ; $user_id = $user - ID ; ? Finding A Username, Based On User ID ?php $user = new WP_User ( 123 ) ; $user_login = $user - user_login ; # Or you could just use this alternate method. $user_login = get_user_field ( "user_login" , 123 ) ; ? Alternative Using get_user_option ( ) Native To WordPress® Most of the s2Member fields are stored in the usermeta table ( a WordPress® standard ), so they could also be retrieved with WordPress® Function → get_user_option() if you prefer, which is already native to WordPress®. That being said, s2Member\API_Functions → get_user_field() is provided by s2Member as a way to retrieve almost anything. ?php $s2member_custom = get_user_option ( "s2member_custom" ) ; # Custom String value for the current User. $s2member_subscr_id = get_user_option ( "s2member_subscr_id" ) ; # Paid Subscr. ID for the current User. $s2member_subscr_gateway = get_user_option ( "s2member_subscr_gateway" ) ; # Paid Subscr. Gateway Code for the current User. $s2member_registration_ip = get_user_option ( "s2member_registration_ip" ) ; # IP the current User had during registration. $s2member_custom_fields = get_user_option ( "s2member_custom_fields" ) ; # Associative array of all Custom Registration Fields. $s2member_file_download_access_log = get_user_option ( "s2member_file_download_access_log" ) ; # Associative array of all File Downloads by the current User. $s2member_auto_eot_time = get_user_option ( "s2member_auto_eot_time" ) ; # Auto EOT-Time for the current User ( when applicable ). $s2member_last_payment_time = get_user_option ( "s2member_last_payment_time" ) ; # Timestamp. Last time an actual payment was received by s2Member. $s2member_paid_registration_times = get_user_option ( "s2member_paid_registration_times" ) ; # Timestamps. Associative array of all Paid Registration Times. ? Practical Shortcode Equivalents [s2Get user_option="s2member_custom" /] # Custom String value for the current User. [s2Get user_option="s2member_subscr_id" /] # Paid Subscr. ID for the current User. [s2Get user_option="s2member_subscr_gateway" /] # Paid Subscr. Gateway Code for the current User. [s2Get user_option="s2member_registration_ip" /] # IP the current User had during registration. Since: 3.5 Parameters: str $field_id - Required. A unique Custom Registration Field ID, that you configured with s2Member. Or, this could be set to any property that exists on the WP_User object for a particular User; ( i.e. id, ID, user_login, user_email, first_name, last_name, display_name, ip, IP, s2member_registration_ip, s2member_custom, s2member_subscr_id, s2member_subscr_or_wp_id, s2member_subscr_gateway, s2member_custom_fields, s2member_file_download_access_log, s2member_auto_eot_time, s2member_last_payment_time, s2member_paid_registration_times, s2member_access_role, s2member_access_level, s2member_access_label, s2member_access_ccaps, etc, etc. ). int $user_id - Optional. Defaults to the current User's ID. Returns: mixed - The value of the requested field, or false if the field does not exist. See Also: s2Member\API_Functions → s2member_registration_time() s2Member\API_Functions → s2member_paid_registration_time() WordPress® Function → get_user_option() WordPress® Function → update_user_option() WordPress® Function → wp_get_current_user() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1121 is_category_permitted_by_s2member() public bool is_category_permitted_by_s2member (int $cat_id) Conditional to determine if a specific Category is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_category_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_category_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $cat_id ( int Required ). This should be a WordPress® Category ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_category_permitted_by_s2member( 123 ) ) echo 'Category ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_category_permitted_by_s2member(123)] Category ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $cat_id - Required. This should be a WordPress® Category ID. Returns: bool - True if the current User IS permitted, else false if the Category is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1053 is_category_protected_by_s2member() public array|bool is_category_protected_by_s2member (int $cat_id, bool $check_user) Conditional to determine if a specific Category is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $cat_id ( int Required ). This should be a WordPress® Category ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Category is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_category_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_category_protected_by_s2member( 123 ) ) echo 'Category ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_category_protected_by_s2member(123)] Category ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $cat_id - Required. This should be a WordPress® Category ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Category is not protected ( i.e. available publicly ). When/if the Category IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Category. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1576 is_page_permitted_by_s2member() public bool is_page_permitted_by_s2member (int $page_id) Conditional to determine if a specific Page is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_page_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_page_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $page_id ( int Required ). This should be a WordPress® Page ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_page_permitted_by_s2member( 123 ) ) echo 'Page ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_page_permitted_by_s2member(123)] Page ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $page_id - Required. This should be a WordPress® Page ID. Returns: bool - True if the current User IS permitted, else false if the Page is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1508 is_page_protected_by_s2member() public array|bool is_page_protected_by_s2member (int $page_id, bool $check_user) Conditional to determine if a specific Page is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $page_id ( int Required ). This should be a WordPress® Page ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Page is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_page_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_page_protected_by_s2member( 123 ) ) echo 'Page ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_page_protected_by_s2member(123)] Page ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $page_id - Required. This should be a WordPress® Page ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Page is not protected ( i.e. available publicly ). When/if the Page IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Page. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #961 is_permitted_by_s2member() public bool is_permitted_by_s2member (int|str $what, str $type) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $what ( int|str Optional ). Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. If you pass in an ID, s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. If you pass in a URL or URI, s2Member will ONLY check URI Restrictions, because it has no ID to work with. This is useful though. Some protected content is not associated with an ID. In those cases, URI Restrictions are all the matter. Note: when passing in a URL or URI, the $type parameter must be set to URI or uri. Case insensitive. Parameter $type ( str Optional ). One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Code Sample Using Function Parameters ?php if (is_permitted_by_s2member( 123 ) ) echo 'Post or Page ID #123 is permitted by s2Member.' ; else if (is_permitted_by_s2member( 332 , "tag" ) ) echo 'Tag ID #332 is permitted by s2Member.' ; else if (is_permitted_by_s2member( 554 , "category" ) ) echo 'Category ID #554 is permitted by s2Member.' ; else if (is_permitted_by_s2member( "http://example.com/members/" , "uri" ) ) echo 'This URL is permitted by s2Member.' ; else if (is_permitted_by_s2member( "/members/" , "uri" ) ) echo 'This URI is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_permitted_by_s2member(123)] Post or Page ID #123 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(332, tag)] Tag ID #332 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(554, category)] Category ID #554 is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(http://example.com/members/, uri)] This URL is permitted by s2Member. [/s2If] [s2If is_permitted_by_s2member(/members/, uri)] This URI is permitted by s2Member. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $what - Optional. Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. str $type - Optional. One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Returns: bool - True if the current User IS permitted, else false if the content is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1433 is_post_permitted_by_s2member() public bool is_post_permitted_by_s2member (int $post_id) Conditional to determine if a specific Post or Custom Post Type is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_post_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_post_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $post_id ( int Required ). This should be a WordPress® Post ID, or a Custom Post Type ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_post_permitted_by_s2member( 123 ) ) echo 'Post ID #123 is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_post_permitted_by_s2member(123)] Post ID #123 is permitted by s2Member. [/s2If] Since: 3.5 Parameters: int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID. Returns: bool - True if the current User IS permitted, else false if the Post is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1365 is_post_protected_by_s2member() public array|bool is_post_protected_by_s2member (int $post_id, bool $check_user) Conditional to determine if a specific Post ( or Custom Post Type ) is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $post_id ( int Required ). This should be a WordPress® Post ID, or a Custom Post Type ID. s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Post is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_post_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_post_protected_by_s2member( 123 ) ) echo 'Post ID #123 is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_post_protected_by_s2member(123)] Post ID #123 is protected by s2Member. [/s2If] Since: 3.5 Parameters: int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Post is not protected ( i.e. available publicly ). When/if the Post IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Post. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #839 is_protected_by_s2member() public array|bool is_protected_by_s2member (int|str $what, str $type, bool $check_user) Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $what ( int|str Optional ). Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. If you pass in an ID, s2Member will check everything, including your configured URI Restrictions against the ID. In other words, s2Member is capable of determining a URI based on the ID that you pass in. So using an ID results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. If you pass in a URL or URI, s2Member will ONLY check URI Restrictions, because it has no ID to work with. This is useful though. Some protected content is not associated with an ID. In those cases, URI Restrictions are all the matter. Note: when passing in a URL or URI, the $type parameter must be set to URI or uri. Case insensitive. Parameter $type ( str Optional ). One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the content is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_protected_by_s2member( 123 ) ) echo 'Post or Page ID #123 is protected by s2Member.' ; else if (is_protected_by_s2member( 332 , "tag" ) ) echo 'Tag ID #332 is protected by s2Member.' ; else if (is_protected_by_s2member( 554 , "category" ) ) echo 'Category ID #554 is protected by s2Member.' ; else if (is_protected_by_s2member( "http://example.com/members/" , "uri" ) ) echo 'This URL is protected by URI Restrictions.' ; else if (is_protected_by_s2member( "/members/" , "uri" ) ) echo 'This URI is protected by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_protected_by_s2member(123)] Post or Page ID #123 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(332, tag)] Tag ID #332 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(554, category)] Category ID #554 is protected by s2Member. [/s2If] [s2If is_protected_by_s2member(http://example.com/members/, uri)] This URL is protected by URI Restrictions. [/s2If] [s2If is_protected_by_s2member(/members/, uri)] This URI is protected by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $what - Optional. Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine. str $type - Optional. One of category, tag, post, page, singular or uri. Defaults to singular ( i.e. a Post or Page ). bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the content is not protected ( i.e. available publicly ). When/if content IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the content. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1290 is_tag_permitted_by_s2member() public bool is_tag_permitted_by_s2member (int|str $tag_id_slug_or_name) Conditional to determine if a specific Tag is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_tag_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_tag_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $tag_id_slug_or_name ( int|str Required ). This should be a WordPress® Tag ID, Tag Slug, or Tag Name. s2Member will check everything, including your configured URI Restrictions against the ID, or Slug, or Name. In other words, s2Member is capable of determining a URI based on the ID, or Slug, or Name that you pass in. So using an ID, or Slug, or Name results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Code Sample Using Function Parameters ?php if (is_tag_permitted_by_s2member( 123 ) ) echo 'Tag ID #123 is permitted by s2Member.' ; else if (is_tag_permitted_by_s2member( "members-only" ) ) echo 'Tag Slug (members-only) is permitted by s2Member.' ; else if (is_tag_permitted_by_s2member( "Members Only" ) ) echo 'Tag Name (Members Only) is permitted by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_tag_permitted_by_s2member(123)] Tag ID #123 is permitted by s2Member. [/s2If] [s2If is_tag_permitted_by_s2member(members-only)] Tag Slug (members-only) is permitted by s2Member. [/s2If] NOTE: It's NOT possible to check a Tag Named "Members Only" with [s2If /], because Shortcode Conditionals may NOT contain spaces in their argument values. If you're using [s2If /] to check a Tag, please use the Slug or ID instead. *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name. Returns: bool - True if the current User IS permitted, else false if the Tag is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1209 is_tag_protected_by_s2member() public array|bool is_tag_protected_by_s2member (int|str $tag_id_slug_or_name, bool $check_user) Conditional to determine if a specific Tag is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $tag_id_slug_or_name ( int|str Required ). This should be a WordPress® Tag ID, Tag Slug, or Tag Name. s2Member will check everything, including your configured URI Restrictions against the ID, Slug, or Name. In other words, s2Member is capable of determining a URI based on the ID, or Slug, or Name that you pass in. So using an ID, or Slug, or Name results in an all-inclusive scan against your configured Restrictions, including any URI Restrictions that you may have configured. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the Tag is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_tag_permitted_by_s2member(). Code Sample Using Function Parameters ?php if (is_tag_protected_by_s2member( 123 ) ) echo 'Tag ID #123 is protected by s2Member.' ; else if (is_tag_protected_by_s2member( "members-only" ) ) echo 'Tag Slug (members-only) is protected by s2Member.' ; else if (is_tag_protected_by_s2member( "Members Only" ) ) echo 'Tag Name (Members Only) is protected by s2Member.' ; ? Shortcode Conditional Equivalent [s2If is_tag_protected_by_s2member(123)] Tag ID #123 is protected by s2Member. [/s2If] [s2If is_tag_protected_by_s2member(members-only)] Tag Slug (members-only) is protected by s2Member. [/s2If] NOTE: It's NOT possible to check a Tag Named "Members Only" with [s2If /], because Shortcode Conditionals may NOT contain spaces in their argument values. If you're using [s2If /] to check a Tag, please use the Slug or ID instead. *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the Tag is not protected ( i.e. available publicly ). When/if the Tag IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Tag. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1733 is_uri_permitted_by_s2member() public bool is_uri_permitted_by_s2member (str $uri_or_full_url) Conditional to determine if a specific URI or URL is permitted by s2Member, with consideration given to the current User's Role/Capabilites. This function is similar to s2Member\API_Functions → is_uri_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functions → is_uri_protected_by_s2member() does; it only returns true|false. Extra Detail On Function Parameters Parameter $uri_or_full_url ( str Required ). This should be a URI starting with /, or a full URL is also fine. Important Notes About This Function This function will ONLY test against URI Restrictions you've configured with s2Member. If you need an all-inclusive test, please use s2Member\API_Functions → is_permitted_by_s2member() with an ID. Code Sample Using Function Parameters ?php if (is_uri_permitted_by_s2member( "/members-only/sub-section" ) ) echo 'The URI (/members-only/sub-section) is permitted by URI Restrictions.' ; else if (is_uri_permitted_by_s2member( "http://example.com/members-only/sub-section" ) ) echo 'The URL (http://example.com/members-only/sub-section) is permitted by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_uri_permitted_by_s2member(/members-only/sub-section)] The URI (/members-only/sub-section) is permitted by URI Restrictions. [/s2If] [s2If is_uri_permitted_by_s2member(http://example.com/members-only/sub-section)] The URL (http://example.com/members-only/sub-section) is permitted by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: str $uri_or_full_url - Required. This should be a URI starting with /, or a full URL is also fine. Returns: bool - True if the current User IS permitted, else false if the URI or URL is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1658 is_uri_protected_by_s2member() public array|bool is_uri_protected_by_s2member (str $uri_or_full_url, bool $check_user) Conditional to determine if a specific URI or URL is protected by s2Member; without considering the current User's Role/Capabilites. Extra Detail On Function Parameters Parameter $uri_or_full_url ( str Required ). This should be a URI starting with /, or a full URL is also fine. Parameter $check_user ( bool Optional ). Consider the current User? Defaults to false. In other words, by default, this Conditional function is only checking to see if the URI or URL is protected, and that's it. So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will. When $check_user is true, this function behaves like s2Member\API_Functions → is_uri_permitted_by_s2member(). Important Notes About This Function This function will ONLY test against URI Restrictions you've configured with s2Member. If you need an all-inclusive test, please use s2Member\API_Functions → is_protected_by_s2member() with an ID. Code Sample Using Function Parameters ?php if (is_uri_protected_by_s2member( "/members-only/sub-section" ) ) echo 'The URI (/members-only/sub-section) is protected by URI Restrictions.' ; else if (is_uri_protected_by_s2member( "http://example.com/members-only/sub-section" ) ) echo 'The URL (http://example.com/members-only/sub-section) is protected by URI Restrictions.' ; ? Shortcode Conditional Equivalent [s2If is_uri_protected_by_s2member(/members-only/sub-section)] The URI (/members-only/sub-section) is protected by URI Restrictions. [/s2If] [s2If is_uri_protected_by_s2member(http://example.com/members-only/sub-section)] The URL (http://example.com/members-only/sub-section) is protected by URI Restrictions. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Parameters: str $uri_or_full_url - Required. This should be a URI starting with /, or a full URL is also fine. bool $check_user - Optional. Consider the current User? Defaults to false. Returns: array|bool - A non-empty array ( meaning true ), or false if the URI or URL is not protected ( i.e. available publicly ). When/if the URI or URL IS protected, the return array will include one of these keys [ "s2member_(level|sp|ccap)_req" ] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the URI or URL. In other words, the reason why it's protected; based on your s2Member configuration. See Also: s2Member\API_Functions → is_protected_by_s2member() s2Member\API_Functions → is_permitted_by_s2member() s2Member\API_Functions → is_category_protected_by_s2member() s2Member\API_Functions → is_category_permitted_by_s2member() s2Member\API_Functions → is_tag_protected_by_s2member() s2Member\API_Functions → is_tag_permitted_by_s2member() s2Member\API_Functions → is_post_protected_by_s2member() s2Member\API_Functions → is_post_permitted_by_s2member() s2Member\API_Functions → is_page_protected_by_s2member() s2Member\API_Functions → is_page_permitted_by_s2member() s2Member\API_Functions → is_uri_protected_by_s2member() s2Member\API_Functions → is_uri_permitted_by_s2member() s2Member\API_Functions → attach_s2member_query_filters() s2Member\API_Functions → detach_s2member_query_filters() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #54 is_user_not_logged_in() public bool is_user_not_logged_in () Conditional to determine if the current User is NOT logged in. Counterpart WordPress® Function → is_user_logged_in() already exists in the WordPress® core. Code Sample Using Both Functions ?php if ( is_user_logged_in ( ) ) echo 'You ARE logged in.' ; else if (is_user_not_logged_in( ) ) echo 'You are NOT logged in.' ; ? Shortcode Conditional Equivalent [s2If is_user_logged_in()] You ARE logged in. [/s2If] [s2If is_user_not_logged_in()] You are NOT logged in. [/s2If] *but please note, else if() logic is not possible with [s2If /]. Since: 3.5 Returns: bool - True if the current User is NOT logged in, else false. See Also: WordPress® Function → is_user_logged_in() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1879 s2member_file_download_key() public str s2member_file_download_key (str $file, str|bool $directive) Generates a File Download Key that provides access to a File protected by s2Member. By default, s2Member uses your Basic Download Restrictions. For more information on this, please check your Dashboard under: s2Member - Download Options - Basic Download Restrictions. Advanced Download Restrictions Or, you can also force s2Member to allow File Downloads, using an extra query string parameter s2member_file_download_key. A File Download Key is passed through this parameter; it tells s2Member to allow the download of this particular file, regardless of Membership Level; and WITHOUT checking any Basic Restrictions, that you may, or may not, have configured. Code Sample Using A Download Key a href="/?s2member_file_download=file.zip&s2member_file_download_key=?php echo s2member_file_download_key( "file.zip" ) ; ?"Download Now/a Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). This API Funtion produces a time-sensitive File Download Key that is unique to each and every visitor. Each Key it produces ( at the time it is produced ), will be valid for the current day, and only for a specific IP address and User-Agent string; as detected by s2Member. This makes it possible for you to create links on your site, which provide access to protected File Downloads; without having to worry about one visitor sharing their link with another. When /?s2member_file_download_key = a valid Key generated by this function, it works independently from Member Level Access. That is, a visitor does NOT have to be logged in to receive access; they just need a valid Key. Using this advanced technique, you could extend s2Member's file protection routines, or even combine them with Specific Post/Page Access, and more. The possibilities are limitless really. Since: 3.5 Parameters: str $file - Location of the protected File, relative to the /s2member-files/ directory. str|bool $directive - Optional. Defaults to false. If you set this to any non-zero value ( i.e. the string universal ), the resulting Key will be universal ( i.e. valid for any User, at any time, from any browser ). That is to say; universal, for this particular File. It is also possible to pass in the $directive string ip-forever, making the Key last forever, but only for a specific IP address. Returns: str - The File Download Key. Which is an MD5 hash ( always 32 characters ), URL-safe. Todo: Create a Shortcode equivalent. Allow custom expiration times. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1963 s2member_paid_registration_time() public int s2member_paid_registration_time (str $level, int $user_id) Retrieves a Paid Registration Time for the current User, and/or for a particular User. NOTE A Paid Registration Time, is NOT necessarily related specifically to a Payment. s2Member records a Paid Registration Time, anytime a User acquires paid Membership Level Access. In other words, if you create a new User inside your Dashboard at a Membership Level greater than Level #0, s2Member will record a Paid Registration Time immediately, because Membership Levels 0, are reserved for paying Members. s2Member monitors changes to all User accounts, and records the first Paid Registration Time for each Member, at each paid Membership Level. So, s2Member stores the first Time a Member reaches each Level of paid access; and s2Member does NOT care if they actually paid, or not. Code Sample Using Function Parameters ?php $time = s2member_registration_time ( ) ; # first registration time ( free or otherwise ). $time = s2member_paid_registration_time ( ) ; # first "paid" registration and/or upgrade time. $time = s2member_paid_registration_time ( "level1" ) ; # first "paid" registration or upgrade time at Level#1. $time = s2member_paid_registration_time ( "level2" ) ; # first "paid" registration or upgrade time at Level#2. $time = s2member_paid_registration_time ( "level3" ) ; # first "paid" registration or upgrade time at Level#3. $time = s2member_paid_registration_time ( "level4" ) ; # first "paid" registration or upgrade time at Level#4. ? Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). Since: 3.5 Parameters: str $level - Optional. Defaults to the first/initial Paid Registration Time, regardless of Level#. int $user_id - Optional. Defaults to the current User's ID. Returns: int - A Unix Timestamp. See Also: s2Member\API_Functions → get_user_field() Todo: Create a Shortcode equivalent. [ back to top ] s2member-pro\includes\functions\separates\gateways\authnet\authnet-api-functions.inc.php at line #50 s2member_pro_authnet_s2p_v_query_ok() public bool s2member_pro_authnet_s2p_v_query_ok (str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. This can be used for verifying the integrity of variables in a success query string. Example usage: if (s2member_pro_authnet_s2p_v_query_ok( $_SERVER [ "QUERY_STRING" ] ) ) { } Since: 1.5 Parameters: str $qs - Optional. Defaults to $_SERVER [ "QUERY_STRING" ] . book $ignore_timestamp - Optional. If true, timestamp is ignored. Defaults to false. Returns: bool - True if the query string is OK/verified, else false. [ back to top ] s2member-pro\includes\functions\api-functions.inc.php at line #104 s2member_pro_login_widget() public str s2member_pro_login_widget (array $options, array $args) Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file. This function will return the HTML output from the widget function call. Example usage: ?php echo s2member_pro_login_widget( ) ; ? The $options parameter (array) is completely optional ( i.e. NOT required ). It can be passed in as an array of options; overriding some or all of these defaults: "title" = "Membership Login" Title when NOT logged in, or leave this blank if you'd prefer not to show a title. "signup_url" = "%%automatic%%" Full Signup URL, or use %%automatic%% for the Membership Options Page. If you leave this blank, it will not be shown. "login_redirect" = "" Empty ( i.e. "" ) = Login Welcome Page, %%previous%% = Previous Page, %%home%% = Home Page, or use a full URL of your own. "logged_out_code" = "" HTML/PHP code to display when logged out. May also contain WP Shortcodes if you like. "profile_title" = "My Profile Summary" Title when a User is logged in. Or you can leave this blank if you'd prefer not to show a title. "display_gravatar" = "1" Display Gravatar image when logged in? 1 = yes, 0 = no. Gravatars are based on email address. "link_gravatar" = "1" Link Gravatar image to Gravatar.com? 1 = yes, 0 = no. Allows Users to setup a Gravatar. "display_name" = "1" Display the current User's WordPress® "Display Name" when logged in? 1 = yes, 0 = no. "logged_in_code" = "" HTML/PHP code to display when logged in. May also contain WP Shortcodes if you like. "logout_redirect" = "%%home%%" Empty ( i.e. "" ) = Login Screen, %%previous%% = Previous Page, %%home%% = Home Page, or use a full URL of your own. "my_account_url" = "%%automatic%%" Full URL of your own, or use %%automatic%% for the Login Welcome Page. Leave empty to not show this at all. "my_profile_url" = "%%automatic%%" Full URL of your own, or use %%automatic%% for a JavaScript popup. Leave empty to not show this at all. The $args parameter (array) is also completely optional ( i.e. NOT required ). It can be passed in as an array of options: overriding some or all of these defaults: "before_widget" = "" HTML code to display before the widget. "before_title" = "h3" HTML code to display before the title. "after_title" = "/h3" HTML code to display after the title. "after_widget" = "" HTML code to display after the widget. Since: 1.5 Parameters: array $options - Optional. See function description for details. array $args - Optional. See function description for details. Returns: str - The Pro Login Widget, HTML markup. [ back to top ] s2member-pro\includes\functions\separates\gateways\paypal\paypal-api-functions.inc.php at line #50 s2member_pro_paypal_s2p_v_query_ok() public bool s2member_pro_paypal_s2p_v_query_ok (str $qs, book $ignore_timestamp) Verifies s2p-v in a given query string argument; from a custom URL for success. This can be used for verifying the integrity of variables in a success query string. Example usage: if (s2member_pro_paypal_s2p_v_query_ok( $_SERVER [ "QUERY_STRING" ] ) ) { } Since: 1.5 Parameters: str $qs - Optional. Defaults to $_SERVER [ "QUERY_STRING" ] . book $ignore_timestamp - Optional. If true, timestamp is ignored. Defaults to false. Returns: bool - True if the query string is OK/verified, else false. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #1918 s2member_registration_time() public int s2member_registration_time (int $user_id) Obtains the Registration Time for the current User, and/or for a particular User. The Registration Time, is the time at which the Username was created for the account, that's it. There's nothing special about this. This simply returns a Unix Timestamp. Code Sample Using Function Parameters ?php if (s2member_registration_time( ) = strtotime ( "-30 days" ) ) echo 'The current User has existed for at least 30 days.' ; else if (s2member_registration_time( 123 ) = strtotime ( "-30 days" ) ) echo 'User with ID #123 has existed for at least 30 days.' ; ? Shortcode Equivalent There is NO Shortcode equivalent for this ( yet ). Since: 3.5 Parameters: int $user_id - Optional. Defaults to the current User's ID. Returns: int - A Unix Timestamp. The Registration Time, is the time at which the Username was created for the account, that's it. See Also: s2Member\API_Functions → get_user_field() Todo: Create a Shortcode equivalent. [ back to top ] s2member\includes\functions\api-functions.inc.php at line #591 user_cannot() public bool user_cannot (int|str $id, str $capability) Conditional to determine if a specific User does NOT have a specific Capability or Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (user_can( 123 , "access_s2member_level0" ) ) echo 'User ID# 123 CAN access content protected at Level #0.' ; else if (user_cannot( 123 , "access_s2member_level0" ) ) echo 'User ID# 123 CANNOT access content at Level #0.' ; ? Shortcode Conditional Equivalent [s2If user_can(123, access_s2member_level0)] User ID# 123 CAN access content protected at Level #0. [/s2If] [s2If user_cannot(123, access_s2member_level0)] User ID# 123 CANNOT access content at Level #0. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 3.5 Parameters: int|str $id - A numeric WordPress® User ID. str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Returns: bool - True if the specific User does NOT have the specified Capability or Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #132 user_is() public bool user_is (int|str $id, str $role) Conditional to determine if a specific User is/has a specific Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Both Functions ?php if (user_is( 123 , "subscriber" ) ) echo 'User ID# 123 is a Free Subscriber at Level #0.' ; else if (user_is( 123 , "s2member_level1" ) ) echo 'User ID# 123 is a Member at Level #1.' ; else if (user_can( 123 , "access_s2member_level2" ) ) echo 'User ID# 123 has access to content protected at Level #2.' ; # But, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If user_is(123, subscriber)] User ID# 123 is a Free Subscriber at Level #0. [/s2If] [s2If user_is(123, s2member_level1)] User ID# 123 is a Member at Level #1. [/s2If] [s2If user_can(123, access_s2member_level2)] User ID# 123 has access to content protected at Level #2. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 110524RC Parameters: int|str $id - A numeric WordPress® User ID. str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the specific User is/has the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] s2member\includes\functions\api-functions.inc.php at line #210 user_is_not() public bool user_is_not (int|str $id, str $role) Conditional to determine if a specific User is/does NOT have a specific Role. Another function WordPress® Function → user_can() already exists in the WordPress® core. Code Sample Using Three Functions ?php if (user_is( 123 , "subscriber" ) ) echo 'User ID# 123 is a Free Subscriber at Level #0.' ; else if (user_is( 123 , "s2member_level1" ) ) echo 'User ID# 123 is a Member at Level #1.' ; else if (user_can( 123 , "access_s2member_level2" ) && user_is_not( 123 , "s2member_level2" ) ) echo 'User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member.' ; # So, (important) they could actually be a Level #3 or #4 Member; # because Membership Levels provide incremental access. ? Shortcode Conditional Equivalent [s2If user_is(123, subscriber)] User ID# 123 is a Free Subscriber at Level #0. [/s2If] [s2If user_is(123, s2member_level1)] User ID# 123 is a Member at Level #1. [/s2If] [s2If user_can(123, access_s2member_level2) AND user_is_not(123, s2member_level2)] User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member. [/s2If] but please note, else if() logic is not possible with [s2If /]. Membership Levels Provide Incremental Access A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3. A Member with Level 3 access, will also be able to access Levels 0, 1, 2. A Member with Level 2 access, will also be able to access Levels 0, 1 A Member with Level 1 access, will also be able to access Level 0. A Subscriber with Level 0 access, can ONLY access Level 0. A public Visitor will have NO access to protected content. WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 ( a Free Subscriber ). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched. Since: 110524RC Parameters: int|str $id - A numeric WordPress® User ID. str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ). Returns: bool - True if the specific User is/does NOT have the specified Role, else false. See Also: s2Member\API_Functions → user_is() s2Member\API_Functions → user_is_not() s2Member\API_Functions → current_user_is() s2Member\API_Functions → current_user_is_not() s2Member\API_Functions → current_user_is_for_blog() s2Member\API_Functions → current_user_is_not_for_blog() s2Member\API_Functions → user_cannot() s2Member\API_Functions → current_user_cannot() s2Member\API_Functions → current_user_cannot_for_blog() WordPress® Function → user_can() WordPress® Function → current_user_can() WordPress® Function → current_user_can_for_blog() [ back to top ] Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Summary Functions Hooks/Filters Function Summary | Function Detail(!-- :: s-words --)

Statistics: Posted by System Robot — July 11th, 2011, 2:58 pm


]]>
2011-07-09T05:04:11-05:00 http://www.primothemes.com/forums/viewtopic.php?t=12453&p=24746#p24746 <![CDATA[s2Member v111220 / Package s2Member\API_Fu...]]>
s2Member v111220
Package s2Member\API_Functions ( Functions )
Docs updated: December 20, 2011, 9:44 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — July 9th, 2011, 5:04 am


]]>