( 48 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 array | get_s2member_custom_fields(int|str $user_id) Custom Registration/Profile Field configuration. |
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/Capabilities. |
public bool | Conditional to determine if the current User is NOT logged in. |
public str | s2member_decrypt(str $base64, str $key) Two-way RIJNDAEL 256 encryption/decryption, with a URL-safe base64 wrapper. |
public str | s2member_encrypt(str $string, str $key, bool $w_md5_cs) Two-way RIJNDAEL 256 encryption/decryption, with a URL-safe base64 wrapper. |
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 str | s2member_file_download_url(array $config, bool $get_streamer_array) Generates a File Download URL that provides access to a File protected by s2Member. |
public int | s2member_last_login_time(int $user_id) Obtains the Last Login Time for the current User, and/or for a particular User. |
public array | s2member_login_ips_for(str $username) Gets login IPs for a particular username. |
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 $url_uri_query, bool $ignore_time, str|int $exp_secs) 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 array | s2member_pro_payflow_rbp_for_user(str|int $user_id) Pulls an array of details from PayPal® Pro (Payflow™ Edition) API; related to a customer's Recurring Billing Profile. |
public array | s2member_pro_payflow_rbp_times_for_user(str|int $user_id) Pulls last/next billing times from the PayPal® Pro (Payflow™ Edition) API; associated with a customer's Recurring Billing Profile. |
public array | s2member_pro_paypal_rbp_for_user(str|int $user_id) Pulls an array of details from the PayPal® Pro API; related to a customer's Recurring Billing Profile. |
public array | s2member_pro_paypal_rbp_times_for_user(str|int $user_id) Pulls last/next billing times from the PayPal® Pro API; associated with a customer's Recurring Billing Profile. |
public bool | s2member_pro_paypal_s2p_v_query_ok(str $url_uri_query, bool $ignore_time, str|int $exp_secs) 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 str|bool | s2member_shorten_url(str $url, str $api_sp, bool $try_backups) Shortens a long URL, based on s2Member configuration. |
public int | s2member_total_downloads_of(str $file, str|int $user_id, bool $check_archives_too) Total downloads of a particular file; possibly by a particular User. |
public int | s2member_total_unique_downloads_of(str $file, str|int $user_id, bool $check_archives_too) Total unique downloads of a particular file; possibly by a particular User. |
public array | s2member_user_downloads(str|int $user_id, str $not_counting_this_particular_file) Retrieves an array of details, related to a User's File Downloads. |
public str | Can be used to auto-fill the invoice for PayPal® Button Codes, with a unique Code~IP combination. |
public str | s2member_xdecrypt(str $base64, str $key) Two-way XOR encryption/decryption, with a URL-safe base64 wrapper. |
public str | s2member_xencrypt(str $string, str $key, bool $w_md5_cs) Two-way XOR encryption/decryption, with a URL-safe base64 wrapper. |
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. |
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
.
<?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(); ?>
There is NO Shortcode equivalent for this.
3.5
null
s2Member\API_Functions → detach_s2member_query_filters()
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.
<?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.'; ?>
but please note,
[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]
else if()
logic is not possible with [s2If /]
.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.
3.5
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
).
bool - True if the current User does NOT have the specified Capability or Role, else false.
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()
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.
<?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).'; ?>
but please note,
[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]
else if()
logic is not possible with [s2If /]
.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.
3.5
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
).
bool - True if the current User does NOT have the specified Capability or Role, else false.
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()
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.
<?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. ?>
but please note,
[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)] You DO have access to content protected at Level #2. [/s2If]
else if()
logic is not possible with [s2If /]
.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.
3.5
str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+
, administrator
, editor
, author
, contributor
, subscriber
).
bool - True if the current User is/has the specified Role, else false.
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()
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.
<?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. ?>
but please note,
[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]
else if()
logic is not possible with [s2If /]
.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.
3.5
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
).
bool - True if the current User is/has the specified Role, on the specified Blog, else false.
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()
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.
<?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. ?>
but please note,
[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]
else if()
logic is not possible with [s2If /]
.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.
3.5
str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+
, administrator
, editor
, author
, contributor
, subscriber
).
bool - True if the current User is/does NOT have the specified Role, else false.
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()
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.
<?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. ?>
but please note,
[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]
else if()
logic is not possible with [s2If /]
.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.
3.5
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
).
bool - True if the current User is/does NOT have the specified Role, on the specified Blog, else false.
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()
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
.
<?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(); ?>
There is NO Shortcode equivalent for this.
3.5
null
s2Member\API_Functions → attach_s2member_query_filters()
public array get_s2member_custom_fields (int|str $user_id)
Custom Registration/Profile Field configuration.
Provides information about the configuration of each Custom Registration/Profile Field.
Returns an associative array with all Custom Field configurations (and User values too, if $user_id
is passed in).
<?php $fields = get_s2member_custom_fields(); print_r($fields["my_field_id"]["config"]); # The Unique Field ID you configured with s2Member. ?>
<?php $fields = get_s2member_custom_fields(123); echo $fields["my_field_id"]["user_value"]; # The Unique Field ID you configured with s2Member. print_r($fields["my_field_id"]["config"]); # The Unique Field ID you configured with s2Member. ?>
[s2Get user_field="my_field_id" /] # The Unique Field ID you configured with s2Member.
110912
int|str $user_id - Optional. If supplied, the user_value
for each Custom Field will be included too.
array - An associative array with all Custom Field configurations (and User values too, if $user_id
is supplied).
s2Member\API_Functions → get_user_field()
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()
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/Profile Fields configured with s2Member and many other plugins.
<?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. ?>
[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.
<?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/Profile Fields. $s2member_file_download_access_log = get_user_field ("s2member_file_download_access_log"); # Associative array of all File Downloads by the current User, in the current Period (Period is based on a specific User'sallowed_days
, configured in your Basic Download Restrictions, at the User's current Membership Level). $s2member_file_download_access_arc = get_user_field ("s2member_file_download_access_arc"); # Associative array of all File Downloads by the current User, in previous Periods (Periods are based on a specific User'sallowed_days
, configured in your Basic Download Restrictions, at the User's Membership Levels in the past). $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. ?>
[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.
<?php $my_field_data = get_user_field ("my_field_id"); # The Unique Field ID you configured with s2Member. ?>
[s2Get user_field="my_field_id" /] # The Unique Field ID you configured with s2Member.
<?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. ?>
[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.
<?php $user = new WP_User("johndoe22"); $user_id = $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); ?>
get_user_option()
Native To WordPress® 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/Profile Fields. $s2member_file_download_access_log = get_user_option ("s2member_file_download_access_log"); # Associative array of all File Downloads by the current User, in the current Period (Period is based on a specific User'sallowed_days
, configured in your Basic Download Restrictions, at the User's current Membership Level). $s2member_file_download_access_arc = get_user_option ("s2member_file_download_access_arc"); # Associative array of all File Downloads by the current User, in previous Periods (Periods are based on a specific User'sallowed_days
, configured in your Basic Download Restrictions, at the User's Membership Levels in the past). $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. ?>
[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.
3.5
str $field_id - Required. A unique Custom Registration/Profile 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|arc]
, 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.
mixed - The value of the requested field, or false if the field does not exist.
s2Member\API_Functions → get_s2member_custom_fields()
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()
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.
Parameter $cat_id (int Required). This should be a WordPress® Category ID.
<?php if(is_category_permitted_by_s2member(123)) echo 'Category ID #123 is permitted by s2Member.'; ?>
[s2If is_category_permitted_by_s2member(123)] Category ID #123 is permitted by s2Member. [/s2If]
3.5
int $cat_id - Required. This should be a WordPress® Category ID.
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.
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()
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.
Parameter $cat_id (int Required). This should be a WordPress® Category ID.
Parameter $check_user (bool Optional). Consider the current User? Defaults to false.
<?php if(is_category_protected_by_s2member(123)) echo 'Category ID #123 is protected by s2Member.'; ?>
[s2If is_category_protected_by_s2member(123)] Category ID #123 is protected by s2Member. [/s2If]
3.5
int $cat_id - Required. This should be a WordPress® Category ID.
bool $check_user - Optional. Consider the current User? Defaults to false.
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.
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()
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.
Parameter $page_id (int Required). This should be a WordPress® Page ID.
<?php if(is_page_permitted_by_s2member(123)) echo 'Page ID #123 is permitted by s2Member.'; ?>
[s2If is_page_permitted_by_s2member(123)] Page ID #123 is permitted by s2Member. [/s2If]
3.5
int $page_id - Required. This should be a WordPress® Page ID.
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.
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()
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.
Parameter $page_id (int Required). This should be a WordPress® Page ID.
Parameter $check_user (bool Optional). Consider the current User? Defaults to false.
<?php if(is_page_protected_by_s2member(123)) echo 'Page ID #123 is protected by s2Member.'; ?>
[s2If is_page_protected_by_s2member(123)] Page ID #123 is protected by s2Member. [/s2If]
3.5
int $page_id - Required. This should be a WordPress® Page ID.
bool $check_user - Optional. Consider the current User? Defaults to false.
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.
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()
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.
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.
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).
<?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.'; ?>
*but please note,
[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]
else if()
logic is not possible with [s2If /]
.
3.5
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 - 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.
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()
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.
Parameter $post_id (int Required). This should be a WordPress® Post ID, or a Custom Post Type ID.
<?php if(is_post_permitted_by_s2member(123)) echo 'Post ID #123 is permitted by s2Member.'; ?>
[s2If is_post_permitted_by_s2member(123)] Post ID #123 is permitted by s2Member. [/s2If]
3.5
int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID.
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.
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()
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.
Parameter $post_id (int Required). This should be a WordPress® Post ID, or a Custom Post Type ID.
Parameter $check_user (bool Optional). Consider the current User? Defaults to false.
<?php if(is_post_protected_by_s2member(123)) echo 'Post ID #123 is protected by s2Member.'; ?>
[s2If is_post_protected_by_s2member(123)] Post ID #123 is protected by s2Member. [/s2If]
3.5
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.
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.
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()
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.
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.
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.
<?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.'; ?>
*but please note,
[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]
else if()
logic is not possible with [s2If /]
.
3.5
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.
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.
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()
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.
Parameter $tag_id_slug_or_name (int|str Required). This should be a WordPress® Tag ID, Tag Slug, or Tag Name.
<?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.'; ?>
*but please note,
[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.
else if()
logic is not possible with [s2If /]
.
3.5
int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name.
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.
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()
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.
Parameter $tag_id_slug_or_name (int|str Required). This should be a WordPress® Tag ID, Tag Slug, or Tag Name.
Parameter $check_user (bool Optional). Consider the current User? Defaults to false.
<?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.'; ?>
*but please note,
[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.
else if()
logic is not possible with [s2If /]
.
3.5
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.
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.
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()
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.
Parameter $uri_or_full_url (str Required). This should be a URI starting with /
, or a full URL is also fine.
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.
<?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.'; ?>
*but please note,
[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]
else if()
logic is not possible with [s2If /]
.
3.5
str $uri_or_full_url - Required. This should be a URI starting with /
, or a full URL is also fine.
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.
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()
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/Capabilities.
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.
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.
<?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.'; ?>
*but please note,
[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]
else if()
logic is not possible with [s2If /]
.
3.5
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.
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.
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()
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.
<?php if(is_user_logged_in()) echo 'You ARE logged in.'; else if(is_user_not_logged_in()) echo 'You are NOT logged in.'; ?>
*but please note,
[s2If is_user_logged_in()] You ARE logged in. [/s2If] [s2If is_user_not_logged_in()] You are NOT logged in. [/s2If]
else if()
logic is not possible with [s2If /]
.
3.5
bool - True if the current User is NOT logged in, else false.
WordPress® Function → is_user_logged_in()
public str s2member_decrypt (str $base64, str $key)
Two-way RIJNDAEL 256 encryption/decryption, with a URL-safe base64 wrapper.
Falls back on XOR encryption/decryption when/if mcrypt is not available.
<?php $encrypted = s2member_encrypt("hello"); ?> <?php $decrypted = s2member_decrypt($encrypted); ?>
There is NO Shortcode equivalent for this (yet).
111106
str $base64 - A string of data to decrypt. Should still be base64 encoded.
str $key - Optional. Key used originally for encryption. Defaults to the one configured for s2Member. Short of that, defaults to: wp_salt()
.
str - Decrypted string.
s2Member\API_Functions → s2member_encrypt()
s2Member\API_Functions → s2member_xencrypt()
s2Member\API_Functions → s2member_xdecrypt()
Create a Shortcode equivalent for this function.
public str s2member_encrypt (str $string, str $key, bool $w_md5_cs)
Two-way RIJNDAEL 256 encryption/decryption, with a URL-safe base64 wrapper.
Falls back on XOR encryption/decryption when/if mcrypt is not available.
<?php $encrypted = s2member_encrypt("hello"); ?> <?php $decrypted = s2member_decrypt($encrypted); ?>
There is NO Shortcode equivalent for this (yet).
111106
str $string - A string of data to encrypt.
str $key - Optional. Key used for encryption. Defaults to the one configured for s2Member. Short of that, defaults to: wp_salt()
.
bool $w_md5_cs - Optional. Defaults to true. When true, an MD5 checksum is used in the encrypted string (recommended).
str - Encrypted string.
s2Member\API_Functions → s2member_decrypt()
s2Member\API_Functions → s2member_xencrypt()
s2Member\API_Functions → s2member_xdecrypt()
Create a Shortcode equivalent for this function.
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
.
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.
<a href="/?s2member_file_download=file.zip&s2member_file_download_key=<?php echo s2member_file_download_key("file.zip"); ?>">Download Now</a>
[s2Key file_download="file.zip" directive="" /]
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.
3.5
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.
str - The File Download Key. Which is an MD5 hash (always 32 characters), URL-safe.
s2Member\API_Functions → s2member_file_download_url()
Allow custom expiration times.
public str s2member_file_download_url (array $config, bool $get_streamer_array)
Generates a File Download URL 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
.
<a href="<?php echo s2member_file_download_url(array("file_download" => "file.zip")); ?>">Download Now</a> <a href="<?php echo s2member_file_download_url(array("file_download" => "file.pdf", "file_inline" => true)); ?>">View PDF</a>
<a href="[s2File download="file.zip" /]">Download Now</a> <a href="[s2File download="file.pdf" inline="true" /]">View PDF</a>
Or, you can also force s2Member to allow File Downloads, by requesting a File Download Key ( i.e. file_download_key => true
).
When a File Download Key is requested through this parameter ( i.e. file_download_key => true
); 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.
<a href="<?php echo s2member_file_download_url(array("file_download" => "file.zip", file_download_key => true)); ?>">Download Now</a> <a href="<?php echo s2member_file_download_url(array("file_download" => "file.pdf", file_download_key => true, "file_inline" => true)); ?>">View PDF</a>
<a href="[s2File download="file.zip" download_key="true" /]">Download Now</a> <a href="[s2File download="file.zip" download_key="true" inline="true" /]">View PDF</a>
Parameter $config (array Required). This should be an array with one or more of the following elements.
"file_download" => "file.zip"
Location of the file, relative to the /s2member-files/
directory; or, relative to the root of your Amazon® S3 Bucket, when applicable."file_download_key" => false
Defaults to false
. If true
, s2Member will return a URL with an s2Member-generated File Download Key. You don't need to generate the File Download Key yourself, s2Member does it for you. If you set this to ip-forever
, the File Download Key that s2Member generates will last forever, for a specific IP Address; otherwise, by default, all File Download Keys expire after 24 hours automatically. If you set this to universal
, s2Member will generate a File Download Key that is good for anyone/everyone forever, with NO restrictions on who/where/when a file is accessed (e.g. be careful with this one)."file_stream" => false
Defaults to false
. If true
, s2Member will return a URL containing a parameter/directive, which forces the File Download to take place over the RTMP protocol. This ONLY works when/if s2Member is configured to run with both Amazon® S3/CloudFront. Please note however, it's better to use the example code provided in the your Dashboard. See: s2Member -› Download Options -› JW Player® and the RTMP Protocol
. Also note, if $get_streamer_array
is passed, s2Member will automatically force "file_stream" => true
for you."file_inline" => null
Defaults to null
. If true
, s2Member will serve the file inline, instead of as an actual File Download. If empty, s2Member will look at your Inline File Extensions configuration, and serve the file inline; if, and only if, its extension matches one found in your configuration. By default, s2Member serves all files as attachments (i.e. downloads). Please check your Dashboard regarding Inline File Extensions. Also note, this Shortcode Attribute does NOTHING for files served via Amazon® CloudFront. See the tech-notes listed in the Amazon® CloudFront section of your Dashboard for further details and workarounds."file_storage" => null
Defaults to null
. Can be one of local|s3|cf
. When specified, s2Member will serve the file from a specific source location. For example, if you've configured Amazon® S3 and/or CloudFront; but, there are a few files that you want to upload locally to the /s2member-files/
directory; you can force s2Member to serve a file from local storage by setting "file_storage" => "local"
explicitly."file_remote" => false
Defaults to false
. If true
, s2Member will authenticate access to the File Download via Remote Header Authorization, instead of through your web site. This is similar to .htaccess
protection routines of yester-year. Please check the Remote Authorization and Podcasting section in your Dashboard for further details about how this works."file_ssl" => null
Defaults to null
. If true
, s2Member will generate a File Download URL with an SSL protocol ( i.e. the URL will start with https://
or rtmpe://
). If null
, s2Member will only generate a File Download URL with an SSL protocol, when/if the Post/Page/URL, is also being viewed over SSL. Otherwise, s2Member will use a non-SSL protocol by default."file_rewrite" => false
Defaults to false
. If true
, s2Member will generate a File Download URL that takes full advantage of s2Member's Advanced Mod Rewrite functionality. If you're running an Apache web server, or another server that supports mod_rewrite
, we highly recommend turning this on. s2Member's mod_rewrite
URLs do NOT contain query string parameters, making them more portable/compatible with other software applications and/or plugins for WordPress®."file_rewrite_base" => null
Defaults to null
. If set to a URL, starting with http
or another valid protocol, s2Member will generate a File Download URL that takes full advantage of s2Member's Advanced Mod Rewrite functionality, and it will use the rewrite base URL as a prefix. This could be useful on some WordPress® installations that use advanced directory structures. It could also be useful for site owners using virtual directories that point to /s2member-files/
. Note, if rewrite_base
is set, s2Member will automatically force "rewrite" => true
for you."skip_confirmation" => false
Defaults to false
. If true
, s2Member will generate a File Download URL which contains a directive, telling s2Member NOT to introduce any JavaScript confirmation prompts on your site, for this File Download URL. Please note, s2Member will automatically detect links, anywhere in your content, and/or anywhere in your theme files, that contain s2member_file_download
or s2member-files
. Whenever a logged-in Member clicks a link that contains s2member_file_download
or s2member-files
, the system will politely ask the User to confirm the download using a very intuitive JavaScript confirmation prompt, which contains specific details about your configured download limitations. This way your Members will be aware of how many files they've downloaded in the current period; and they'll be able to make a conscious decision about whether to proceed with a specific download or not."url_to_storage_source" => false
Defaults to false
. If true
, s2Member will generate a File Download URL which points directly to the storage source. This is only functional with Amazon® S3 and/or CloudFront integrations. If you create a URL that points directly to the storage source (i.e. points directly to Amazon® S3 or CloudFront), s2Member will NOT be able to further authenticate the current User/Member; and, s2Member will NOT be able to count the File Download against the current User's account record, because the URL being generated does not pass back through s2Member at all, it points directly to the storage source. For this reason, if you set "url_to_storage_source" => true
, you should also set "check_user" => true
and "count_against_user" => true
, telling s2Member to authenticate the current User, and if authenticated, count this File Download URL against the current User's account record in real-time (i.e. as the URL is being generated), while it still has a chance to do so. This is useful when you stream files over the RTMP protocol; where an http://
URL is not feasible. It also helps in situations where a 3rd-party software application will not work as intended, with s2Member's internal redirection to Amazon® S3/CloudFront files. Important, when "check_user" => true
and/or "count_against_user" => true
, this API Function will return false
in situations where the current User/Member does NOT have access to the file."count_against_user" => false
Defaults to false
. If true
, it will automatically force "check_user" => true
as well. In other words, s2Member will authenticate the current User, and if authenticated, count this File Download URL against the current User's account record in real-time (i.e. as the URL is being generated). This is off by default. By default, s2Member will simply generate a File Download URL, and upon a User/Member clicking the URL, s2Member will authenticate the User/Member at that time, count the File Download against their account record, and serve the File Download. In other words, under normal circumstances, there is no reason to set "check_user" => true
and/or "count_against_user" => true
when generating the URL itself. However, this is a useful config option when "url_to_storage_source" => true
. Please note, when "check_user" => true
and/or "count_against_user" => true
, this API Function will return false
in situations where the current User/Member does NOT have access to the file."check_user => false
Defaults to false
. If true
, s2Member will authenticate the current User before allowing the File Download URL to be generated. This is off by default. By default, s2Member will simply generate a File Download URL, and upon a User/Member clicking the URL, s2Member will authenticate the User/Member at that time, and serve the File Download to the User/Member. In other words, under normal circumstances, there is no reason to set "check_user" => true
and/or "count_against_user" => true
when generating the URL itself. However, this IS a useful config option when "url_to_storage_source" => true
. Please note, when "check_user" => true
and/or "count_against_user" => true
, this API Function will return false
in situations where the current User/Member does NOT have access to the file.Parameter $get_streamer_array (bool Optional). Defaults to false
. If true
, this API Function will return an array with the following elements: streamer
, file
, url
. For further details, please review this section in your Dashboard: s2Member -› Download Options -› JW Player® & RTMP Protocol Examples
. Note, if this is true, s2Member will automatically force "url_to_storage_source" => true
and "file_stream" => true
. For that reason, you should carefully review the details and warning above regarding url_to_storage_source
. If you set $get_streamer_array
, you should also set "check_user" => true
and "count_against_user" => true
.
110926
array $config - Required. This is an array of configuration options associated with permissions being checked against the current User/Member; and also the actual URL generated by this routine. Possible $config
array elements: file_download
(required), file_download_key
, file_stream
, file_inline
, file_storage
, file_remote
, file_ssl
, file_rewrite
, file_rewrite_base
, skip_confirmation
, url_to_storage_source
, count_against_user
, check_user
.
bool $get_streamer_array - Optional. Defaults to false
. If true
, this API Function will return an array with the following elements: streamer
, file
, url
. For further details, please review this section in your Dashboard: s2Member -› Download Options -› JW Player® & RTMP Protocol Examples
. Note, if this is true, s2Member will automatically force "url_to_storage_source" => true
and "file_stream" => true
. For that reason, you should carefully review the details and warning above regarding url_to_storage_source
. If you set $get_streamer_array
, you should also set "check_user" => true
and "count_against_user" => true
.
str - A File Download URL string on success; or an array on success, with elements streamer
, file
, url
when/if $get_streamer_array
is true; else false on any type of failure.
s2Member\API_Functions → s2member_file_download_key()
public int s2member_last_login_time (int $user_id)
Obtains the Last Login Time for the current User, and/or for a particular User.
The Last Login Time, is the time at which the Username last logged into the site. There's nothing special about this. This simply returns a Unix Timestamp.
<?php if(s2member_last_login_time() <= strtotime("-30 days")) echo 'The current User last logged-in over 30 days ago.'; else if(s2member_last_login_time(123) <= strtotime("-30 days")) echo 'User with ID #123 last logged-in over 30 days ago.'; ?>
[s2Get user_option="s2member_last_login_time" /] # Last Login Time.
130210
int $user_id - Optional. Defaults to the current User's ID.
int - A Unix Timestamp. The Last Login Time, is the time at which the Username last logged into the site. If the User has never logged into the site (or s2Member® has never recorded them logging in), this will return 0
.
s2Member\API_Functions → get_user_field()
public array s2member_login_ips_for (str $username)
Gets login IPs for a particular username.
<?php print_r($ips = s2member_login_ips_for("johndoe22")); ?>
There is NO Shortcode equivalent for this (yet).
120728
str $username - A username.
array - An associative array of all IPs associated with a particular username, over the last 30 days. Array keys are IP addresses; array values are UTC timestamps.
Create a Shortcode equivalent for this function.
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.
<?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. ?>
There is NO Shortcode equivalent for this (yet).
3.5
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.
int - A Unix Timestamp.
s2Member\API_Functions → get_user_field()
public bool s2member_pro_authnet_s2p_v_query_ok (str $url_uri_query, bool $ignore_time, str|int $exp_secs)
Verifies s2p-v
in a given query string argument; from a custom URL for success.
This can be used to verify the integrity of variables in a success query string.
Example usage: if(s2member_pro_authnet_s2p_v_query_ok($_SERVER["QUERY_STRING"])){ }
1.5
str $url_uri_query - A full URL, a partial URI, or just the query string.
bool $ignore_time - Optional. Defaults to false. If true, timestamp is ignored.
str|int $exp_secs - Optional. Defaults to (int)10. If $ignore_time
is false, s2Member will check the signature timestamp. By default, the signature timestamp cannot be older than 10 seconds, but you can modify this if you prefer.
bool - True if the query string is OK/verified, else false.
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.1.5
array $options - Optional. See function description for details.
array $args - Optional. See function description for details.
str - The Pro Login Widget, HTML markup.
public array s2member_pro_payflow_rbp_for_user (str|int $user_id)
Pulls an array of details from PayPal® Pro (Payflow™ Edition) API; related to a customer's Recurring Billing Profile.
This function will return an array of data (as described below); else an empty array if no Recurring Billing Profile exists.
Example usage: <?php print_r(s2member_pro_payflow_rbp_for_user(123)); ?>
Array elements returned by this function correlate with the PayPal® Pro (Payflow™ Edition) API call method: ACTION=I
.
Please see https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/wpppe_rp_guide.pdf#page=54.
130405
str|int $user_id - Optional. A specific User ID. Defaults to the current User ID that is logged into the site.
array - An array of data from the PayPal® Pro (Payflow™ Edition) API; else an empty array if no Recurring Billing Profile exists. Array elements returned by this function correlate with the PayPal® Pro (Payflow™ Edition) API call method: ACTION=I
. Please see https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/wpppe_rp_guide.pdf#page=54.
public array s2member_pro_payflow_rbp_times_for_user (str|int $user_id)
Pulls last/next billing times from the PayPal® Pro (Payflow™ Edition) API; associated with a customer's Recurring Billing Profile.
This function will return an array of data (as described below); else an empty array if no Recurring Billing Profile exists.
Example usage: <?php print_r(s2member_pro_payflow_rbp_times_for_user(123)); ?>
Array elements returned by this function include: last_billing_time
, next_billing_time
(both as UTC Unix timestamps).
130405
str|int $user_id - Optional. A specific User ID. Defaults to the current User ID that is logged into the site.
array - Array elements: last_billing_time
, next_billing_time
(both as UTC Unix timestamps); else an empty array if no Recurring Billing Profile exists. If one or more times (e.g. last_billing_time
, next_billing_time
) are irrelevant (i.e. there was no payment received yet; or there are no future payments to receive); that time will default to a value of 0
indicating it's irrelevant and/or not applicable.
public array s2member_pro_paypal_rbp_for_user (str|int $user_id)
Pulls an array of details from the PayPal® Pro API; related to a customer's Recurring Billing Profile.
This function will return an array of data (as described below); else an empty array if no Recurring Billing Profile exists.
Example usage: <?php print_r(s2member_pro_paypal_rbp_for_user(123)); ?>
Array elements returned by this function correlate with the PayPal® Pro API call method: GetRecurringPaymentsProfileDetails
.
Please see https://www.x.com/developers/paypal/documentation-tools/api/getrecurringpaymentsprofiledetails-api-operation-nvp.
130405
str|int $user_id - Optional. A specific User ID. Defaults to the current User ID that is logged into the site.
array - An array of data (from the PayPal® Pro API); else an empty array if no Recurring Billing Profile exists. Array elements returned by this function correlate with the PayPal® Pro API call method: GetRecurringPaymentsProfileDetails
. Please see https://www.x.com/developers/paypal/documentation-tools/api/getrecurringpaymentsprofiledetails-api-operation-nvp.
If your PayPal® Pro account uses the Payflow™ Edition API, please use s2member_pro_payflow_rbp_for_user() instead.
public array s2member_pro_paypal_rbp_times_for_user (str|int $user_id)
Pulls last/next billing times from the PayPal® Pro API; associated with a customer's Recurring Billing Profile.
This function will return an array of data (as described below); else an empty array if no Recurring Billing Profile exists.
Example usage: <?php print_r(s2member_pro_paypal_rbp_times_for_user(123)); ?>
Array elements returned by this function include: last_billing_time
, next_billing_time
(both as UTC Unix timestamps).
130405
str|int $user_id - Optional. A specific User ID. Defaults to the current User ID that is logged into the site.
array - Array elements: last_billing_time
, next_billing_time
(both as UTC Unix timestamps); else an empty array if no Recurring Billing Profile exists. If one or more times (e.g. last_billing_time
, next_billing_time
) are irrelevant (i.e. there was no payment received yet; or there are no future payments to receive); that time will default to a value of 0
indicating it's irrelevant and/or not applicable.
If your PayPal® Pro account uses the Payflow™ Edition API, please use s2member_pro_payflow_rbp_times_for_user() instead.
public bool s2member_pro_paypal_s2p_v_query_ok (str $url_uri_query, bool $ignore_time, str|int $exp_secs)
Verifies s2p-v
in a given query string argument; from a custom URL for success.
This can be used to verify the integrity of variables in a success query string.
Example usage: if(s2member_pro_paypal_s2p_v_query_ok($_SERVER["QUERY_STRING"])){ }
1.5
str $url_uri_query - A full URL, a partial URI, or just the query string.
bool $ignore_time - Optional. Defaults to false. If true, timestamp is ignored.
str|int $exp_secs - Optional. Defaults to (int)10. If $ignore_time
is false, s2Member will check the signature timestamp. By default, the signature timestamp cannot be older than 10 seconds, but you can modify this if you prefer.
bool - True if the query string is OK/verified, else false.
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.
<?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.'; ?>
There is NO Shortcode equivalent for this (yet).
3.5
int $user_id - Optional. Defaults to the current User's ID.
int - A Unix Timestamp. The Registration Time, is the time at which the Username was created for the account, that's it.
s2Member\API_Functions → get_user_field()
public str|bool s2member_shorten_url (str $url, str $api_sp, bool $try_backups)
Shortens a long URL, based on s2Member configuration.
<?php echo s2member_shorten_url("http://www.example.com/a-long-url/"); ?> <?php echo s2member_shorten_url("http://www.example.com/a-long-url/", "tiny_url"); ?> <?php echo s2member_shorten_url("http://www.example.com/a-long-url/", "goo_gl"); ?>
There is NO Shortcode equivalent for this (yet).
111004
str $url - A full/long URL to be shortened.
str $api_sp - Optional. A specific URL shortening API to use. Defaults to that which is configured in the s2Member Dashboard. Normally tiny_url
by default.
bool $try_backups - Defaults to true. If a failure occurs with the first API, we'll try others until we have success.
str|bool - The shortened URL on success, else false on failure.
Create a Shortcode equivalent for this function.
public int s2member_total_downloads_of (str $file, str|int $user_id, bool $check_archives_too)
Total downloads of a particular file; possibly by a particular User.
File:example-file.zip
, has been downloaded a total of <?php echo s2member_total_downloads_of("example-file.zip"); ?> times; collectively, among all Users/Members, for all time (includes all duplicate downloads of the same file by the same User/Member). File:example-file.zip
, has been downloaded a total of <?php echo s2member_total_downloads_of("example-file.zip", false, false); ?> times; collectively, among all Users/Members, in this Period only (includes all duplicate downloads of the same file by the same User/Member). File:example-file.zip
, has been downloaded by User ID# 123, a total of <?php echo s2member_total_downloads_of("example-file.zip", 123); ?> times; for all time, since they first became a User/Member of the site (includes all duplicate downloads of the same file by this User/Member). File:example-file.zip
, has been downloaded by User ID# 123, a total of <?php echo s2member_total_downloads_of("example-file.zip", 123, false); ?> times; in this Period only (includes all duplicate downloads of the same file by this User/Member).
There is NO Shortcode equivalent for this yet.
111026
str $file - Required. Location of the file, relative to the /s2member-files/
directory, or relative to the root of your Amazon® S3 Bucket (when applicable).
str|int $user_id - Optional. If specified, s2Member will return total downloads by a particular User/Member, instead of collectively (i.e among all Users/Members).
bool $check_archives_too - Optional. Defaults to true. When true, s2Member checks its File Download Archive too, instead of ONLY looking at Files downloaded in the current Period. Period is based on your Basic Download Restrictions setting of allowed days across various Levels of Membership, for each respective User/Member. Or, if $user_id
is specified, based solely on a specific User's allowed_days
, configured in your Basic Download Restrictions, at the User's current Membership Level.
int - The total for this particular $file
, based on configuration of function arguments.
Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.
s2Member\API_Functions → s2member_user_downloads()
s2Member\API_Functions → s2member_total_unique_downloads_of()
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
s2Member\API_Constants → S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
s2Member\API_Constants → S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.
Create a Shortcode equivalent.
public int s2member_total_unique_downloads_of (str $file, str|int $user_id, bool $check_archives_too)
Total unique downloads of a particular file; possibly by a particular User.
File:example-file.zip
, has been downloaded a total of <?php echo s2member_total_unique_downloads_of("example-file.zip"); ?> times; collectively, among all Users/Members, for all time (does NOT include duplicate downloads of the same file, in a single Period, by the same User/Member). File:example-file.zip
, has been downloaded a total of <?php echo s2member_total_unique_downloads_of("example-file.zip", false, false); ?> times; collectively, among all Users/Members, in this Period only (does NOT include duplicate downloads of the same file, in a single Period, by the same User/Member). File:example-file.zip
, has been downloaded by User ID# 123, a total of <?php echo s2member_total_unique_downloads_of("example-file.zip", 123); ?> times; for all time, since they first became a User/Member of the site (does NOT include duplicate downloads of the same file, in a single Period, by this User/Member). File:example-file.zip
, has been downloaded by User ID# 123, a total of <?php echo s2member_total_unique_downloads_of("example-file.zip", 123, false); ?> times; in this Period only (does NOT include duplicate downloads of the same file, in a single Period, by this User/Member).
There is NO Shortcode equivalent for this yet.
111026
str $file - Required. Location of the file, relative to the /s2member-files/
directory, or relative to the root of your Amazon® S3 Bucket (when applicable).
str|int $user_id - Optional. If specified, s2Member will return total downloads by a particular User/Member, instead of collectively (i.e among all Users/Members).
bool $check_archives_too - Optional. Defaults to true. When true, s2Member checks its File Download Archive too, instead of ONLY looking at Files downloaded in the current Period. Period is based on your Basic Download Restrictions setting of allowed days across various Levels of Membership, for each respective User/Member. Or, if $user_id
is specified, based solely on a specific User's allowed_days
, configured in your Basic Download Restrictions, at the User's current Membership Level.
int - The total for this particular $file
, based on configuration of function arguments.
Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.
s2Member\API_Functions → s2member_user_downloads()
s2Member\API_Functions → s2member_total_downloads_of()
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
s2Member\API_Constants → S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
s2Member\API_Constants → S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.
Create a Shortcode equivalent.
public array s2member_user_downloads (str|int $user_id, str $not_counting_this_particular_file)
Retrieves an array of details, related to a User's File Downloads.
<?php $user_downloads = s2member_user_downloads(); $specific_user_downloads = s2member_user_downloads(($user_id = 123)); ?>
There is NO Shortcode equivalent for this yet.
111026
str|int $user_id - Optional. Defaults to the currently logged-in User's ID.
str $not_counting_this_particular_file - Optional. If you want to exclude a particular file, relative to the /s2member-files/
directory, or relative to the root of your Amazon® S3 Bucket (when applicable).
array - An array with the following elements... File Downloads allowed for this User: (int)allowed
, Download Period for this User in days: (int)allowed_days
, Files downloaded by this User in the current Period: (int)currently
, log of all Files downloaded in the current Period, with file names/dates: (array)log
, archive of all Files downloaded in prior Periods, with file names/dates: (array)archive
.
Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.
s2Member\API_Functions → s2member_total_downloads_of()
s2Member\API_Functions → s2member_total_unique_downloads_of()
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
s2Member\API_Constants → S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
s2Member\API_Constants → S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
s2Member\API_Constants → S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
s2Member\API_Constants → S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.
Create a Shortcode equivalent.
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 echo s2member_value_for_pp_inv(); ?>
[s2Get constant="S2MEMBER_VALUE_FOR_PP_INV" /] <script type="text/javascript"> document.write(s2member_value_for_pp_inv_gen()); </script>
110720
str - A unique Invoice.
s2Member\API_Constants → S2MEMBER_VALUE_FOR_PP_INV
Create a true Shortcode equivalent function.
public str s2member_xdecrypt (str $base64, str $key)
Two-way XOR encryption/decryption, with a URL-safe base64 wrapper.
<?php $encrypted = s2member_xencrypt("hello"); ?> <?php $decrypted = s2member_xdecrypt($encrypted); ?>
There is NO Shortcode equivalent for this (yet).
111106
str $base64 - A string of data to decrypt. Should still be base64 encoded.
str $key - Optional. Key used originally for encryption. Defaults to the one configured for s2Member. Short of that, defaults to: wp_salt()
.
str - Decrypted string.
s2Member\API_Functions → s2member_xencrypt()
s2Member\API_Functions → s2member_encrypt()
s2Member\API_Functions → s2member_decrypt()
Create a Shortcode equivalent for this function.
public str s2member_xencrypt (str $string, str $key, bool $w_md5_cs)
Two-way XOR encryption/decryption, with a URL-safe base64 wrapper.
<?php $encrypted = s2member_xencrypt("hello"); ?> <?php $decrypted = s2member_xdecrypt($encrypted); ?>
There is NO Shortcode equivalent for this (yet).
111106
str $string - A string of data to encrypt.
str $key - Optional. Key used for encryption. Defaults to the one configured for s2Member. Short of that, defaults to: wp_salt()
.
bool $w_md5_cs - Optional. Defaults to true. When true, an MD5 checksum is used in the encrypted string (recommended).
str - Encrypted string.
s2Member\API_Functions → s2member_xdecrypt()
s2Member\API_Functions → s2member_encrypt()
s2Member\API_Functions → s2member_decrypt()
Create a Shortcode equivalent for this function.
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.
<?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.'; ?>
but please note,
[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]
else if()
logic is not possible with [s2If /]
.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.
3.5
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
).
bool - True if the specific User does NOT have the specified Capability or Role, else false.
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()
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.
<?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. ?>
but please note,
[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]
else if()
logic is not possible with [s2If /]
.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.
110524RC
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
).
bool - True if the specific User is/has the specified Role, else false.
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()
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.
<?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. ?>
but please note,
[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]
else if()
logic is not possible with [s2If /]
.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.
110524RC
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
).
bool - True if the specific User is/does NOT have the specified Role, else false.
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()