Source Code Documentation


Function Summary | Function Detail

Package s2Member\API_Functions ( 48 Functions )


( 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

is_user_not_logged_in()

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

s2member_value_for_pp_inv()

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.

( 48 Functions )
Function Detail

s2member\includes\functions\api-functions.inc.php at line #1799

attach_s2member_query_filters()

public null attach_s2member_query_filters ()

Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content (i.e content NOT available to the current User), is excluded automatically.

This functionality is already built right into s2Member's UI configuration panels, but in cases where a plugin/theme developer needs more control, this may come in handy. In the UI configuration for s2Member, please see: Alternative View Protection.

Code Sample Using s2Member's Query Filters
  1. <?php
  2. attach_s2member_query_filters();
  3. query_posts("posts_per_page=5");
  4. if (have_posts()):
  5. while (have_posts()):
  6. the_post();
  7. # Protected content will be excluded automatically.
  8. # (based on the current User's Role/Capabilities)
  9. endwhile;
  10. endif;
  11. wp_reset_query();
  12. detach_s2member_query_filters();
  13. ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this.

Since:

3.5

Returns:

null

See Also:

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #678

current_user_cannot()

public bool current_user_cannot (str $capability)

Conditional to determine if the current User does NOT have a specific Capability or Role.

Another function WordPress® Functioncurrent_user_can() already exists in the WordPress® core.

Code Sample Using Both Functions
  1. <?php
  2. if(current_user_can("access_s2member_level0"))
  3. echo 'You CAN access content protected at Level #0.';
  4. else if(current_user_cannot("access_s2member_level0"))
  5. echo 'You CANNOT access content protected at Level #0.';
  6. ?>
Shortcode Conditional Equivalent
  1. [s2If current_user_can(access_s2member_level0)]
  2. You CAN access content protected at Level #0.
  3. [/s2If]
  4. [s2If current_user_cannot(access_s2member_level0)]
  5. You CANNOT access content protected at Level #0.
  6. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

3.5

Parameters:

str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Or a Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ).

Returns:

bool - True if the current User does NOT have the specified Capability or Role, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #748

current_user_cannot_for_blog()

public bool current_user_cannot_for_blog (int|str $blog_id, str $capability)

Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network.

Another function WordPress® Functioncurrent_user_can_for_blog() already exists in the WordPress® core.

Code Sample Using Both Functions
  1. <?php
  2. if(current_user_can_for_blog(5, "access_s2member_level0"))
  3. echo 'You CAN access content protected at Level #0 (on Blog ID 5).';
  4. else if(current_user_cannot_for_blog(5, "access_s2member_level0"))
  5. echo 'You CANNOT access content protected at Level #0 (on Blog ID 5).';
  6. ?>
Shortcode Conditional Equivalent
  1. [s2If current_user_can_for_blog(5, access_s2member_level0)]
  2. You CAN access content protected at Level #0 (on Blog ID 5).
  3. [/s2If]
  4. [s2If current_user_cannot_for_blog(5, access_s2member_level0)]
  5. You CANNOT access content protected at Level #0 (on Blog ID 5).
  6. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

3.5

Parameters:

int|str $blog_id - A WordPress® Blog ID (must be numeric).

str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ). Or a Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ).

Returns:

bool - True if the current User does NOT have the specified Capability or Role, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #294

current_user_is()

public bool current_user_is (str $role)

Conditional to determine if the current User is/has a specific Role.

Another function WordPress® Functioncurrent_user_can() already exists in the WordPress® core.

Code Sample Using Both Functions
  1. <?php
  2. if(current_user_is("subscriber"))
  3. echo 'You ARE a Free Subscriber at Level #0.';
  4. else if(current_user_is("s2member_level1"))
  5. echo 'You ARE a Member at Level #1.';
  6. else if(current_user_can("access_s2member_level2"))
  7. echo 'You DO have access to content protected at Level #2.';
  8. # But, (important) they could actually be a Level #3 or #4 Member;
  9. # because Membership Levels provide incremental access.
  10. ?>

Shortcode Conditional Equivalent
  1. [s2If current_user_is(subscriber)]
  2. You ARE a Free Subscriber at Level #0.
  3. [/s2If]
  4. [s2If current_user_is(s2member_level1)]
  5. You ARE a Member at Level #1.
  6. [/s2If]
  7. [s2If current_user_can(access_s2member_level2)]
  8. You DO have access to content protected at Level #2.
  9. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

3.5

Parameters:

str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ).

Returns:

bool - True if the current User is/has the specified Role, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #461

current_user_is_for_blog()

public bool current_user_is_for_blog (int|str $blog_id, str $role)

Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network.

Another function WordPress® Functioncurrent_user_can_for_blog() already exists in the WordPress® core.

Code Sample Using Three Functions
  1. <?php
  2. if(current_user_is("subscriber"))
  3. echo 'You ARE a Free Subscriber at Level #0 (on this Blog).';
  4. else if(current_user_is_for_blog(5, "subscriber"))
  5. echo 'You ARE a Free Subscriber at Level #0 (on Blog ID 5).';
  6. else if(current_user_is_for_blog(5, "s2member_level1"))
  7. echo 'You ARE a Member at Level #1 (on Blog ID 5).';
  8. else if(current_user_can_for_blog(5, "access_s2member_level2"))
  9. echo 'You DO have access to content protected at Level #2 (on Blog ID 5).';
  10. # But, (important) they could actually be a Level #3 or #4 Member (on Blog ID 5);
  11. # because Membership Levels provide incremental access.
  12. ?>
Shortcode Conditional Equivalent
  1. [s2If current_user_is(subscriber)]
  2. You ARE a Free Subscriber at Level #0 (on this Blog).
  3. [/s2If]
  4. [s2If current_user_is_for_blog(5, subscriber)]
  5. You ARE a Free Subscriber at Level #0 (on Blog ID 5).
  6. [/s2If]
  7. [s2If current_user_is_for_blog(5, s2member_level1)]
  8. You ARE a Member at Level #1 (on Blog ID 5).
  9. [/s2If]
  10. [s2If current_user_can_for_blog(5, access_s2member_level2)]
  11. You DO have access to content protected at Level #2 (on Blog ID 5).
  12. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

3.5

Parameters:

int|str $blog_id - A WordPress® Blog ID (must be numeric).

str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ).

Returns:

bool - True if the current User is/has the specified Role, on the specified Blog, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #378

current_user_is_not()

public bool current_user_is_not (str $role)

Conditional to determine if the current User is/does NOT have a specific Role.

Another function WordPress® Functioncurrent_user_can() already exists in the WordPress® core.

Code Sample Using Three Functions
  1. <?php
  2. if(current_user_is("subscriber"))
  3. echo 'You ARE a Free Subscriber at Level #0.';
  4. else if(current_user_is("s2member_level1"))
  5. echo 'You ARE a Member at Level #1.';
  6. else if(current_user_can("access_s2member_level2") && current_user_is_not("s2member_level2"))
  7. echo 'You DO have access to content protected at Level #2, but you are NOT a Level #2 Member.';
  8. # So, (important) they could actually be a Level #3 or #4 Member;
  9. # because Membership Levels provide incremental access.
  10. ?>
Shortcode Conditional Equivalent
  1. [s2If current_user_is(subscriber)]
  2. You ARE a Free Subscriber at Level #0.
  3. [/s2If]
  4. [s2If current_user_is(s2member_level1)]
  5. You ARE a Member at Level #1.
  6. [/s2If]
  7. [s2If current_user_can(access_s2member_level2) AND current_user_is_not(s2member_level2)]
  8. You DO have access to content protected at Level #2, but you are NOT a Level #2 Member.
  9. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

3.5

Parameters:

str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ).

Returns:

bool - True if the current User is/does NOT have the specified Role, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #540

current_user_is_not_for_blog()

public bool current_user_is_not_for_blog (int|str $blog_id, str $role)

Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network.

Another function WordPress® Functioncurrent_user_can_for_blog() already exists in the WordPress® core.

Code Sample Using Three Functions
  1. <?php
  2. if(current_user_is_for_blog(5, "subscriber"))
  3. echo 'You ARE a Free Subscriber at Level #0 (on Blog ID 5).';
  4. else if(current_user_can_for_blog(5, "access_s2member_level1") && current_user_is_not_for_blog(5, "s2member_level1"))
  5. 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).';
  6. # So, (important) they could actually be a Level #2 or #3 or #4 Member (on Blog ID 5);
  7. # because Membership Levels provide incremental access.
  8. ?>
Shortcode Conditional Equivalent
  1. [s2If current_user_is_for_blog(5, subscriber)]
  2. You ARE a Free Subscriber at Level #0 (on Blog ID 5).
  3. [/s2If]
  4. [s2If current_user_can_for_blog(5, access_s2member_level1) AND current_user_is_not_for_blog(5, s2member_level1)]
  5. 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).
  6. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

3.5

Parameters:

int|str $blog_id - A WordPress® Blog ID (must be numeric).

str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ).

Returns:

bool - True if the current User is/does NOT have the specified Role, on the specified Blog, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1845

detach_s2member_query_filters()

public null detach_s2member_query_filters ()

Allows plugin/theme developers to pre-filter WP Queries easily, so that protected content (i.e content NOT available to the current User), is excluded automatically.

This functionality is already built right into s2Member's UI configuration panels, but in cases where a plugin/theme developer needs more control, this may come in handy. In the UI configuration for s2Member, please see: Alternative View Protection.

Code Sample Using s2Member's Query Filters
  1. <?php
  2. attach_s2member_query_filters();
  3. query_posts("posts_per_page=5");
  4. if (have_posts()):
  5. while (have_posts()):
  6. the_post();
  7. # Protected content will be excluded automatically.
  8. # (based on the current User's Role/Capabilities)
  9. endwhile;
  10. endif;
  11. wp_reset_query();
  12. detach_s2member_query_filters();
  13. ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this.

Since:

3.5

Returns:

null

See Also:

s2Member\API_Functionsattach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2458

get_s2member_custom_fields()

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 Code Sample
  1. <?php
  2. $fields = get_s2member_custom_fields();
  3. print_r($fields["my_field_id"]["config"]); # The Unique Field ID you configured with s2Member.
  4. ?>
PHP Code Sample (Specific User)
  1. <?php
  2. $fields = get_s2member_custom_fields(123);
  3. echo $fields["my_field_id"]["user_value"]; # The Unique Field ID you configured with s2Member.
  4. print_r($fields["my_field_id"]["config"]); # The Unique Field ID you configured with s2Member.
  5. ?>
Shortcode Alternative (Specific User)
  1. [s2Get user_field="my_field_id" /] # The Unique Field ID you configured with s2Member.

Since:

110912

Parameters:

int|str $user_id - Optional. If supplied, the user_value for each Custom Field will be included too.

Returns:

array - An associative array with all Custom Field configurations (and User values too, if $user_id is supplied).

See Also:

s2Member\API_Functionsget_user_field()

s2Member\API_Functionss2member_registration_time()

s2Member\API_Functionss2member_paid_registration_time()

WordPress® Functionget_user_option()

WordPress® Functionupdate_user_option()

WordPress® Functionwp_get_current_user()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2411

get_user_field()

public mixed get_user_field (str $field_id, int $user_id)

A powerful function that can retrieve almost anything you need to know about the current User, and/or a particular User.

Scans all properties of the WP_User object. It defaults to the current User, but can also be used to obtain information about a particular User, by passing in a specific User ID.

It can be used to retrieve basic information like first_name, last_name, user_email, user_login. It can also be used to retrieve User Meta/Options, Role/Capabilities, and even supports Custom Registration/Profile Fields configured with s2Member and many other plugins.

Here Are A Few Examples
  1. <?php
  2. $user_login = get_user_field ("user_login"); # Username for the current User.
  3. $user_email = get_user_field ("user_email"); # Email Address for the current User.
  4. $first_name = get_user_field ("first_name"); # First Name for the current User.
  5. $last_name = get_user_field ("last_name"); # Last Name for the current User.
  6. $full_name = get_user_field ("full_name"); # First and Last Name for the current User.
  7. $display_name = get_user_field ("display_name"); # Display Name for the current User.
  8. ?>
Shortcode Equivalents
  1. [s2Get user_field="user_login" /] # Username for the current User.
  2. [s2Get user_field="user_email" /] # Email Address for the current User.
  3. [s2Get user_field="first_name" /] # First Name for the current User.
  4. [s2Get user_field="last_name" /] # Last Name for the current User.
  5. [s2Get user_field="full_name" /] # First and Last Name for the current User.
  6. [s2Get user_field="display_name" /] # Display Name for the current User.
More Examples With s2Member Fields
  1. <?php
  2. $s2member_custom = get_user_field ("s2member_custom"); # Custom String value for the current User.
  3. $s2member_subscr_id = get_user_field ("s2member_subscr_id"); # Paid Subscr. ID for the current User.
  4. $s2member_subscr_or_wp_id = get_user_field ("s2member_subscr_or_wp_id"); # Paid Subscr. ID, else WordPress® User ID.
  5. $s2member_subscr_gateway = get_user_field ("s2member_subscr_gateway"); # Paid Subscr. Gateway Code for the current User.
  6. $s2member_registration_ip = get_user_field ("s2member_registration_ip"); # IP the current User had during registration.
  7. $s2member_custom_fields = get_user_field ("s2member_custom_fields"); # Associative array of all Custom Registration/Profile Fields.
  8. $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).
  9. $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).
  10. $s2member_auto_eot_time = get_user_field ("s2member_auto_eot_time"); # Auto EOT-Time for the current User (when applicable).
  11. $s2member_last_payment_time = get_user_field ("s2member_last_payment_time"); # Timestamp. Last time an actual payment was received by s2Member.
  12. $s2member_paid_registration_times = get_user_field ("s2member_paid_registration_times"); # Timestamps. Associative array of all Paid Registration Times.
  13. $s2member_access_role = get_user_field ("s2member_access_role"); # A WordPress® Role ID (i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber).
  14. $s2member_access_level = get_user_field ("s2member_access_level"); # An s2Member Membership Access Level number.
  15. $s2member_access_label = get_user_field ("s2member_access_label"); # An s2Member Membership Access Label (i.e. Bronze, Gold, Silver, Platinum, or whatever is configured).
  16. $s2member_access_ccaps = get_user_field ("s2member_access_ccaps"); # An array of Custom Capabilities the current User has (i.e. music,videos).
  17. $s2member_login_counter = get_user_field ("s2member_login_counter"); # Number of times the User has logged into your site.
  18. ?>
Practical Shortcode Equivalents
  1. [s2Get user_field="s2member_custom" /] # Custom String value for the current User.
  2. [s2Get user_field="s2member_subscr_id" /] # Paid Subscr. ID for the current User.
  3. [s2Get user_field="s2member_subscr_or_wp_id" /] # Paid Subscr. ID, else WordPress® User ID.
  4. [s2Get user_field="s2member_subscr_gateway" /] # Paid Subscr. Gateway Code for the current User.
  5. [s2Get user_field="s2member_registration_ip" /] # IP Address the current User had during registration.
  6. [s2Get user_field="s2member_access_role" /] # A WordPress® Role ID (i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber).
  7. [s2Get user_field="s2member_access_level" /] # An s2Member Membership Access Level number.
  8. [s2Get user_field="s2member_access_label" /] # An s2Member Membership Access Label (i.e. Bronze, Gold, Silver, Platinum, or whatever is configured).
  9. [s2Get user_field="s2member_login_counter" /] # Number of times the User has logged into your site.
Pulling Data From Your Own Custom Fields
  1. <?php
  2. $my_field_data = get_user_field ("my_field_id"); # The Unique Field ID you configured with s2Member.
  3. ?>
Shortcode Equivalent
  1. [s2Get user_field="my_field_id" /] # The Unique Field ID you configured with s2Member.
Pulling Data For A Particular User ID
  1. <?php
  2. $user_login = get_user_field ("user_login", 123); # Username for the User with ID #123.
  3. $user_email = get_user_field ("user_email", 123); # Email Address for the User with ID #123.
  4. $first_name = get_user_field ("first_name", 123); # First Name for the User with ID #123.
  5. $last_name = get_user_field ("last_name", 123); # Last Name for the User with ID #123.
  6. $full_name = get_user_field ("full_name", 123); # First and Last Name for the User with ID #123.
  7. $display_name = get_user_field ("display_name", 123); # Display Name for the User with ID #123.
  8. ?>
Shortcode Equivalents
  1. [s2Get user_field="user_login" user_id="123" /] # Username for the User with ID #123.
  2. [s2Get user_field="user_email" user_id="123" /] # Email Address for the User with ID #123.
  3. [s2Get user_field="first_name" user_id="123" /] # First Name for the User with ID #123.
  4. [s2Get user_field="last_name" user_id="123" /] # Last Name for the User with ID #123.
  5. [s2Get user_field="full_name" user_id="123" /] # First and Last Name for the User with ID #123.
  6. [s2Get user_field="display_name" user_id="123" /] # Display Name for the User with ID #123.
Finding A User ID, Based On Username
  1. <?php
  2. $user = new WP_User("johndoe22");
  3. $user_id = $user->ID;
  4. ?>
Finding A Username, Based On User ID
  1. <?php
  2. $user = new WP_User(123);
  3. $user_login = $user->user_login;
  4. # Or you could just use this alternate method.
  5. $user_login = get_user_field ("user_login", 123);
  6. ?>

Alternative Using get_user_option() Native To WordPress®
Most of the s2Member fields are stored in the usermeta table (a WordPress® standard), so they could also be retrieved with WordPress® Functionget_user_option() if you prefer, which is already native to WordPress®. That being said, s2Member\API_Functionsget_user_field() is provided by s2Member as a way to retrieve almost anything.
  1. <?php
  2. $s2member_custom = get_user_option ("s2member_custom"); # Custom String value for the current User.
  3. $s2member_subscr_id = get_user_option ("s2member_subscr_id"); # Paid Subscr. ID for the current User.
  4. $s2member_subscr_gateway = get_user_option ("s2member_subscr_gateway"); # Paid Subscr. Gateway Code for the current User.
  5. $s2member_registration_ip = get_user_option ("s2member_registration_ip"); # IP the current User had during registration.
  6. $s2member_custom_fields = get_user_option ("s2member_custom_fields"); # Associative array of all Custom Registration/Profile Fields.
  7. $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).
  8. $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).
  9. $s2member_auto_eot_time = get_user_option ("s2member_auto_eot_time"); # Auto EOT-Time for the current User (when applicable).
  10. $s2member_last_payment_time = get_user_option ("s2member_last_payment_time"); # Timestamp. Last time an actual payment was received by s2Member.
  11. $s2member_paid_registration_times = get_user_option ("s2member_paid_registration_times"); # Timestamps. Associative array of all Paid Registration Times.
  12. $s2member_login_counter = get_user_option ("s2member_login_counter"); # Number of times the User has logged into your site.
  13. ?>
Practical Shortcode Equivalents
  1. [s2Get user_option="s2member_custom" /] # Custom String value for the current User.
  2. [s2Get user_option="s2member_subscr_id" /] # Paid Subscr. ID for the current User.
  3. [s2Get user_option="s2member_subscr_gateway" /] # Paid Subscr. Gateway Code for the current User.
  4. [s2Get user_option="s2member_registration_ip" /] # IP the current User had during registration.
  5. [s2Get user_option="s2member_login_counter" /] # Number of times the User has logged in.

Since:

3.5

Parameters:

str $field_id - Required. A unique Custom Registration/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.

Returns:

mixed - The value of the requested field, or false if the field does not exist.

See Also:

s2Member\API_Functionsget_s2member_custom_fields()

s2Member\API_Functionss2member_registration_time()

s2Member\API_Functionss2member_paid_registration_time()

WordPress® Functionget_user_option()

WordPress® Functionupdate_user_option()

WordPress® Functionwp_get_current_user()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1139

is_category_permitted_by_s2member()

public bool is_category_permitted_by_s2member (int $cat_id)

Conditional to determine if a specific Category is permitted by s2Member, with consideration given to the current User's Role/Capabilites.

This function is similar to s2Member\API_Functionsis_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_Functionsis_category_protected_by_s2member() does; it only returns true|false.

Extra Detail On Function Parameters

Parameter $cat_id (int Required). This should be a WordPress® Category ID.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_category_permitted_by_s2member(123))
  3. echo 'Category ID #123 is permitted by s2Member.';
  4. ?>
Shortcode Conditional Equivalent
  1. [s2If is_category_permitted_by_s2member(123)]
  2. Category ID #123 is permitted by s2Member.
  3. [/s2If]

Since:

3.5

Parameters:

int $cat_id - Required. This should be a WordPress® Category ID.

Returns:

bool - True if the current User IS permitted, else false if the Category is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1071

is_category_protected_by_s2member()

public array|bool is_category_protected_by_s2member (int $cat_id, bool $check_user)

Conditional to determine if a specific Category is protected by s2Member; without considering the current User's Role/Capabilites.

Extra Detail On Function Parameters

Parameter $cat_id (int Required). This should be a WordPress® Category ID.

Parameter $check_user (bool Optional). Consider the current User? Defaults to false.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_category_protected_by_s2member(123))
  3. echo 'Category ID #123 is protected by s2Member.';
  4. ?>
Shortcode Conditional Equivalent
  1. [s2If is_category_protected_by_s2member(123)]
  2. Category ID #123 is protected by s2Member.
  3. [/s2If]

Since:

3.5

Parameters:

int $cat_id - Required. This should be a WordPress® Category ID.

bool $check_user - Optional. Consider the current User? Defaults to false.

Returns:

array|bool - A non-empty array (meaning true), or false if the Category is not protected (i.e. available publicly). When/if the Category IS protected, the return array will include one of these keys ["s2member_(level|sp|ccap)_req"] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Category. In other words, the reason why it's protected; based on your s2Member configuration.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1594

is_page_permitted_by_s2member()

public bool is_page_permitted_by_s2member (int $page_id)

Conditional to determine if a specific Page is permitted by s2Member, with consideration given to the current User's Role/Capabilites.

This function is similar to s2Member\API_Functionsis_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_Functionsis_page_protected_by_s2member() does; it only returns true|false.

Extra Detail On Function Parameters

Parameter $page_id (int Required). This should be a WordPress® Page ID.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_page_permitted_by_s2member(123))
  3. echo 'Page ID #123 is permitted by s2Member.';
  4. ?>
Shortcode Conditional Equivalent
  1. [s2If is_page_permitted_by_s2member(123)]
  2. Page ID #123 is permitted by s2Member.
  3. [/s2If]

Since:

3.5

Parameters:

int $page_id - Required. This should be a WordPress® Page ID.

Returns:

bool - True if the current User IS permitted, else false if the Page is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1526

is_page_protected_by_s2member()

public array|bool is_page_protected_by_s2member (int $page_id, bool $check_user)

Conditional to determine if a specific Page is protected by s2Member; without considering the current User's Role/Capabilites.

Extra Detail On Function Parameters

Parameter $page_id (int Required). This should be a WordPress® Page ID.

Parameter $check_user (bool Optional). Consider the current User? Defaults to false.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_page_protected_by_s2member(123))
  3. echo 'Page ID #123 is protected by s2Member.';
  4. ?>
Shortcode Conditional Equivalent
  1. [s2If is_page_protected_by_s2member(123)]
  2. Page ID #123 is protected by s2Member.
  3. [/s2If]

Since:

3.5

Parameters:

int $page_id - Required. This should be a WordPress® Page ID.

bool $check_user - Optional. Consider the current User? Defaults to false.

Returns:

array|bool - A non-empty array (meaning true), or false if the Page is not protected (i.e. available publicly). When/if the Page IS protected, the return array will include one of these keys ["s2member_(level|sp|ccap)_req"] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Page. In other words, the reason why it's protected; based on your s2Member configuration.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #979

is_permitted_by_s2member()

public bool is_permitted_by_s2member (int|str $what, str $type)

Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is permitted by s2Member, with consideration given to the current User's Role/Capabilites.

This function is similar to s2Member\API_Functionsis_protected_by_s2member(), except this function considers the current User's Role/Capabilites. Also, this function does NOT return the array like s2Member\API_Functionsis_protected_by_s2member() does; it only returns true|false.

Extra Detail On Function Parameters

Parameter $what (int|str Optional). Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine.

Parameter $type (str Optional). One of category, tag, post, page, singular or uri. Defaults to singular (i.e. a Post or Page).

Code Sample Using Function Parameters
  1. <?php
  2. if(is_permitted_by_s2member(123))
  3. echo 'Post or Page ID #123 is permitted by s2Member.';
  4. else if(is_permitted_by_s2member(332, "tag"))
  5. echo 'Tag ID #332 is permitted by s2Member.';
  6. else if(is_permitted_by_s2member(554, "category"))
  7. echo 'Category ID #554 is permitted by s2Member.';
  8. else if(is_permitted_by_s2member("http://example.com/members/", "uri"))
  9. echo 'This URL is permitted by s2Member.';
  10. else if(is_permitted_by_s2member("/members/", "uri"))
  11. echo 'This URI is permitted by s2Member.';
  12. ?>
Shortcode Conditional Equivalent
  1. [s2If is_permitted_by_s2member(123)]
  2. Post or Page ID #123 is permitted by s2Member.
  3. [/s2If]
  4. [s2If is_permitted_by_s2member(332, tag)]
  5. Tag ID #332 is permitted by s2Member.
  6. [/s2If]
  7. [s2If is_permitted_by_s2member(554, category)]
  8. Category ID #554 is permitted by s2Member.
  9. [/s2If]
  10. [s2If is_permitted_by_s2member(http://example.com/members/, uri)]
  11. This URL is permitted by s2Member.
  12. [/s2If]
  13. [s2If is_permitted_by_s2member(/members/, uri)]
  14. This URI is permitted by s2Member.
  15. [/s2If]
*but please note, else if() logic is not possible with [s2If /].

Since:

3.5

Parameters:

int|str $what - Optional. Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine.

str $type - Optional. One of category, tag, post, page, singular or uri. Defaults to singular (i.e. a Post or Page).

Returns:

bool - True if the current User IS permitted, else false if the content is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1451

is_post_permitted_by_s2member()

public bool is_post_permitted_by_s2member (int $post_id)

Conditional to determine if a specific Post or Custom Post Type is permitted by s2Member, with consideration given to the current User's Role/Capabilites.

This function is similar to s2Member\API_Functionsis_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_Functionsis_post_protected_by_s2member() does; it only returns true|false.

Extra Detail On Function Parameters

Parameter $post_id (int Required). This should be a WordPress® Post ID, or a Custom Post Type ID.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_post_permitted_by_s2member(123))
  3. echo 'Post ID #123 is permitted by s2Member.';
  4. ?>
Shortcode Conditional Equivalent
  1. [s2If is_post_permitted_by_s2member(123)]
  2. Post ID #123 is permitted by s2Member.
  3. [/s2If]

Since:

3.5

Parameters:

int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID.

Returns:

bool - True if the current User IS permitted, else false if the Post is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1383

is_post_protected_by_s2member()

public array|bool is_post_protected_by_s2member (int $post_id, bool $check_user)

Conditional to determine if a specific Post (or Custom Post Type) is protected by s2Member; without considering the current User's Role/Capabilites.

Extra Detail On Function Parameters

Parameter $post_id (int Required). This should be a WordPress® Post ID, or a Custom Post Type ID.

Parameter $check_user (bool Optional). Consider the current User? Defaults to false.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_post_protected_by_s2member(123))
  3. echo 'Post ID #123 is protected by s2Member.';
  4. ?>
Shortcode Conditional Equivalent
  1. [s2If is_post_protected_by_s2member(123)]
  2. Post ID #123 is protected by s2Member.
  3. [/s2If]

Since:

3.5

Parameters:

int $post_id - Required. This should be a WordPress® Post ID, or a Custom Post Type ID.

bool $check_user - Optional. Consider the current User? Defaults to false.

Returns:

array|bool - A non-empty array (meaning true), or false if the Post is not protected (i.e. available publicly). When/if the Post IS protected, the return array will include one of these keys ["s2member_(level|sp|ccap)_req"] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Post. In other words, the reason why it's protected; based on your s2Member configuration.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #857

is_protected_by_s2member()

public array|bool is_protected_by_s2member (int|str $what, str $type, bool $check_user)

Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is protected by s2Member; without considering the current User's Role/Capabilites.

Extra Detail On Function Parameters

Parameter $what (int|str Optional). Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine.

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.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_protected_by_s2member(123))
  3. echo 'Post or Page ID #123 is protected by s2Member.';
  4. else if(is_protected_by_s2member(332, "tag"))
  5. echo 'Tag ID #332 is protected by s2Member.';
  6. else if(is_protected_by_s2member(554, "category"))
  7. echo 'Category ID #554 is protected by s2Member.';
  8. else if(is_protected_by_s2member("http://example.com/members/", "uri"))
  9. echo 'This URL is protected by URI Restrictions.';
  10. else if(is_protected_by_s2member("/members/", "uri"))
  11. echo 'This URI is protected by URI Restrictions.';
  12. ?>
Shortcode Conditional Equivalent
  1. [s2If is_protected_by_s2member(123)]
  2. Post or Page ID #123 is protected by s2Member.
  3. [/s2If]
  4. [s2If is_protected_by_s2member(332, tag)]
  5. Tag ID #332 is protected by s2Member.
  6. [/s2If]
  7. [s2If is_protected_by_s2member(554, category)]
  8. Category ID #554 is protected by s2Member.
  9. [/s2If]
  10. [s2If is_protected_by_s2member(http://example.com/members/, uri)]
  11. This URL is protected by URI Restrictions.
  12. [/s2If]
  13. [s2If is_protected_by_s2member(/members/, uri)]
  14. This URI is protected by URI Restrictions.
  15. [/s2If]
*but please note, else if() logic is not possible with [s2If /].

Since:

3.5

Parameters:

int|str $what - Optional. Defaults to the current $post ID when called from within The Loop. If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine.

str $type - Optional. One of category, tag, post, page, singular or uri. Defaults to singular (i.e. a Post or Page).

bool $check_user - Optional. Consider the current User? Defaults to false.

Returns:

array|bool - A non-empty array (meaning true), or false if the content is not protected (i.e. available publicly). When/if content IS protected, the return array will include one of these keys ["s2member_(level|sp|ccap)_req"] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the content. In other words, the reason why it's protected; based on your s2Member configuration.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1308

is_tag_permitted_by_s2member()

public bool is_tag_permitted_by_s2member (int|str $tag_id_slug_or_name)

Conditional to determine if a specific Tag is permitted by s2Member, with consideration given to the current User's Role/Capabilites.

This function is similar to s2Member\API_Functionsis_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_Functionsis_tag_protected_by_s2member() does; it only returns true|false.

Extra Detail On Function Parameters

Parameter $tag_id_slug_or_name (int|str Required). This should be a WordPress® Tag ID, Tag Slug, or Tag Name.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_tag_permitted_by_s2member(123))
  3. echo 'Tag ID #123 is permitted by s2Member.';
  4. else if(is_tag_permitted_by_s2member("members-only"))
  5. echo 'Tag Slug (members-only) is permitted by s2Member.';
  6. else if(is_tag_permitted_by_s2member("Members Only"))
  7. echo 'Tag Name (Members Only) is permitted by s2Member.';
  8. ?>
Shortcode Conditional Equivalent
  1. [s2If is_tag_permitted_by_s2member(123)]
  2. Tag ID #123 is permitted by s2Member.
  3. [/s2If]
  4. [s2If is_tag_permitted_by_s2member(members-only)]
  5. Tag Slug (members-only) is permitted by s2Member.
  6. [/s2If]
  7. NOTE: It's NOT possible to check a Tag Named "Members Only" with [s2If /],
  8. because Shortcode Conditionals may NOT contain spaces in their argument values.
  9. If you're using [s2If /] to check a Tag, please use the Slug or ID instead.
*but please note, else if() logic is not possible with [s2If /].

Since:

3.5

Parameters:

int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name.

Returns:

bool - True if the current User IS permitted, else false if the Tag is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1227

is_tag_protected_by_s2member()

public array|bool is_tag_protected_by_s2member (int|str $tag_id_slug_or_name, bool $check_user)

Conditional to determine if a specific Tag is protected by s2Member; without considering the current User's Role/Capabilites.

Extra Detail On Function Parameters

Parameter $tag_id_slug_or_name (int|str Required). This should be a WordPress® Tag ID, Tag Slug, or Tag Name.

Parameter $check_user (bool Optional). Consider the current User? Defaults to false.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_tag_protected_by_s2member(123))
  3. echo 'Tag ID #123 is protected by s2Member.';
  4. else if(is_tag_protected_by_s2member("members-only"))
  5. echo 'Tag Slug (members-only) is protected by s2Member.';
  6. else if(is_tag_protected_by_s2member("Members Only"))
  7. echo 'Tag Name (Members Only) is protected by s2Member.';
  8. ?>
Shortcode Conditional Equivalent
  1. [s2If is_tag_protected_by_s2member(123)]
  2. Tag ID #123 is protected by s2Member.
  3. [/s2If]
  4. [s2If is_tag_protected_by_s2member(members-only)]
  5. Tag Slug (members-only) is protected by s2Member.
  6. [/s2If]
  7. NOTE: It's NOT possible to check a Tag Named "Members Only" with [s2If /],
  8. because Shortcode Conditionals may NOT contain spaces in their argument values.
  9. If you're using [s2If /] to check a Tag, please use the Slug or ID instead.
*but please note, else if() logic is not possible with [s2If /].

Since:

3.5

Parameters:

int|str $tag_id_slug_or_name - Required. This should be a WordPress® Tag ID, Tag Slug, or Tag Name.

bool $check_user - Optional. Consider the current User? Defaults to false.

Returns:

array|bool - A non-empty array (meaning true), or false if the Tag is not protected (i.e. available publicly). When/if the Tag IS protected, the return array will include one of these keys ["s2member_(level|sp|ccap)_req"] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Tag. In other words, the reason why it's protected; based on your s2Member configuration.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1751

is_uri_permitted_by_s2member()

public bool is_uri_permitted_by_s2member (str $uri_or_full_url)

Conditional to determine if a specific URI or URL is permitted by s2Member, with consideration given to the current User's Role/Capabilites.

This function is similar to s2Member\API_Functionsis_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_Functionsis_uri_protected_by_s2member() does; it only returns true|false.

Extra Detail On Function Parameters

Parameter $uri_or_full_url (str Required). This should be a URI starting with /, or a full URL is also fine.

Important Notes About This Function

This function will ONLY test against URI Restrictions you've configured with s2Member. If you need an all-inclusive test, please use s2Member\API_Functionsis_permitted_by_s2member() with an ID.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_uri_permitted_by_s2member("/members-only/sub-section"))
  3. echo 'The URI (/members-only/sub-section) is permitted by URI Restrictions.';
  4. else if(is_uri_permitted_by_s2member("http://example.com/members-only/sub-section"))
  5. echo 'The URL (http://example.com/members-only/sub-section) is permitted by URI Restrictions.';
  6. ?>
Shortcode Conditional Equivalent
  1. [s2If is_uri_permitted_by_s2member(/members-only/sub-section)]
  2. The URI (/members-only/sub-section) is permitted by URI Restrictions.
  3. [/s2If]
  4. [s2If is_uri_permitted_by_s2member(http://example.com/members-only/sub-section)]
  5. The URL (http://example.com/members-only/sub-section) is permitted by URI Restrictions.
  6. [/s2If]
*but please note, else if() logic is not possible with [s2If /].

Since:

3.5

Parameters:

str $uri_or_full_url - Required. This should be a URI starting with /, or a full URL is also fine.

Returns:

bool - True if the current User IS permitted, else false if the URI or URL is NOT available to the current User; based on your configuration of s2Member, and based on the current User's Role/Capabilities.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1676

is_uri_protected_by_s2member()

public array|bool is_uri_protected_by_s2member (str $uri_or_full_url, bool $check_user)

Conditional to determine if a specific URI or URL is protected by s2Member; without considering the current User's Role/Capabilities.

Extra Detail On Function Parameters

Parameter $uri_or_full_url (str Required). This should be a URI starting with /, or a full URL is also fine.

Parameter $check_user (bool Optional). Consider the current User? Defaults to false.

Important Notes About This Function

This function will ONLY test against URI Restrictions you've configured with s2Member. If you need an all-inclusive test, please use s2Member\API_Functionsis_protected_by_s2member() with an ID.

Code Sample Using Function Parameters
  1. <?php
  2. if(is_uri_protected_by_s2member("/members-only/sub-section"))
  3. echo 'The URI (/members-only/sub-section) is protected by URI Restrictions.';
  4. else if(is_uri_protected_by_s2member("http://example.com/members-only/sub-section"))
  5. echo 'The URL (http://example.com/members-only/sub-section) is protected by URI Restrictions.';
  6. ?>
Shortcode Conditional Equivalent
  1. [s2If is_uri_protected_by_s2member(/members-only/sub-section)]
  2. The URI (/members-only/sub-section) is protected by URI Restrictions.
  3. [/s2If]
  4. [s2If is_uri_protected_by_s2member(http://example.com/members-only/sub-section)]
  5. The URL (http://example.com/members-only/sub-section) is protected by URI Restrictions.
  6. [/s2If]
*but please note, else if() logic is not possible with [s2If /].

Since:

3.5

Parameters:

str $uri_or_full_url - Required. This should be a URI starting with /, or a full URL is also fine.

bool $check_user - Optional. Consider the current User? Defaults to false.

Returns:

array|bool - A non-empty array (meaning true), or false if the URI or URL is not protected (i.e. available publicly). When/if the URI or URL IS protected, the return array will include one of these keys ["s2member_(level|sp|ccap)_req"] indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the URI or URL. In other words, the reason why it's protected; based on your s2Member configuration.

See Also:

s2Member\API_Functionsis_protected_by_s2member()

s2Member\API_Functionsis_permitted_by_s2member()

s2Member\API_Functionsis_category_protected_by_s2member()

s2Member\API_Functionsis_category_permitted_by_s2member()

s2Member\API_Functionsis_tag_protected_by_s2member()

s2Member\API_Functionsis_tag_permitted_by_s2member()

s2Member\API_Functionsis_post_protected_by_s2member()

s2Member\API_Functionsis_post_permitted_by_s2member()

s2Member\API_Functionsis_page_protected_by_s2member()

s2Member\API_Functionsis_page_permitted_by_s2member()

s2Member\API_Functionsis_uri_protected_by_s2member()

s2Member\API_Functionsis_uri_permitted_by_s2member()

s2Member\API_Functionsattach_s2member_query_filters()

s2Member\API_Functionsdetach_s2member_query_filters()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #54

is_user_not_logged_in()

public bool is_user_not_logged_in ()

Conditional to determine if the current User is NOT logged in.

Counterpart WordPress® Functionis_user_logged_in() already exists in the WordPress® core.

Code Sample Using Both Functions
  1. <?php
  2. if(is_user_logged_in())
  3. echo 'You ARE logged in.';
  4. else if(is_user_not_logged_in())
  5. echo 'You are NOT logged in.';
  6. ?>
Shortcode Conditional Equivalent
  1. [s2If is_user_logged_in()]
  2. You ARE logged in.
  3. [/s2If]
  4. [s2If is_user_not_logged_in()]
  5. You are NOT logged in.
  6. [/s2If]
*but please note, else if() logic is not possible with [s2If /].

Since:

3.5

Returns:

bool - True if the current User is NOT logged in, else false.

See Also:

WordPress® Functionis_user_logged_in()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2600

s2member_decrypt()

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 Code Samples
  1. <?php $encrypted = s2member_encrypt("hello"); ?>
  2. <?php $decrypted = s2member_decrypt($encrypted); ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this (yet).

Since:

111106

Parameters:

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().

Returns:

str - Decrypted string.

See Also:

s2Member\API_Functionss2member_encrypt()

s2Member\API_Functionss2member_xencrypt()

s2Member\API_Functionss2member_xdecrypt()

Todo:

Create a Shortcode equivalent for this function.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2565

s2member_encrypt()

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 Code Samples
  1. <?php $encrypted = s2member_encrypt("hello"); ?>
  2. <?php $decrypted = s2member_decrypt($encrypted); ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this (yet).

Since:

111106

Parameters:

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).

Returns:

str - Encrypted string.

See Also:

s2Member\API_Functionss2member_decrypt()

s2Member\API_Functionss2member_xencrypt()

s2Member\API_Functionss2member_xdecrypt()

Todo:

Create a Shortcode equivalent for this function.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1969

s2member_file_download_key()

public str s2member_file_download_key (str $file, str|bool $directive)

Generates a File Download Key that provides access to a File protected by s2Member.

By default, s2Member uses your Basic Download Restrictions. For more information on this, please check your Dashboard under: s2Member -› Download Options -› Basic Download Restrictions.

Advanced Download Restrictions

Or, you can also force s2Member to allow File Downloads, using an extra query string parameter s2member_file_download_key. A File Download Key is passed through this parameter; it tells s2Member to allow the download of this particular file, regardless of Membership Level; and WITHOUT checking any Basic Restrictions, that you may, or may not have configured.

Code Sample Using A Download Key
  1. <a href="/?s2member_file_download=file.zip&s2member_file_download_key=<?php echo s2member_file_download_key("file.zip"); ?>">Download Now</a>
Shortcode Equivalent
  1. [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.

Since:

3.5

Parameters:

str $file - Location of the protected File, relative to the /s2member-files/ directory.

str|bool $directive - Optional. Defaults to false. If you set this to any non-zero value ( i.e. the string universal ), the resulting Key will be universal (i.e. valid for any User, at any time, from any browser). That is to say; universal, for this particular File. It is also possible to pass in the $directive string ip-forever, making the Key last forever, but only for a specific IP address.

Returns:

str - The File Download Key. Which is an MD5 hash (always 32 characters), URL-safe.

See Also:

s2Member\API_Functionss2member_file_download_url()

Todo:

Allow custom expiration times.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #1917

s2member_file_download_url()

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.

HTML/PHP Code Samples
  1. <a href="<?php echo s2member_file_download_url(array("file_download" => "file.zip")); ?>">Download Now</a>
  2. <a href="<?php echo s2member_file_download_url(array("file_download" => "file.pdf", "file_inline" => true)); ?>">View PDF</a>
Shortcode Equivalents
  1. <a href="[s2File download="file.zip" /]">Download Now</a>
  2. <a href="[s2File download="file.pdf" inline="true" /]">View PDF</a>

Advanced Download Restrictions

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.

HTML/PHP Code Samples Using A Download Key
  1. <a href="<?php echo s2member_file_download_url(array("file_download" => "file.zip", file_download_key => true)); ?>">Download Now</a>
  2. <a href="<?php echo s2member_file_download_url(array("file_download" => "file.pdf", file_download_key => true, "file_inline" => true)); ?>">View PDF</a>
Shortcode Equivalents Using A Download Key
  1. <a href="[s2File download="file.zip" download_key="true" /]">Download Now</a>
  2. <a href="[s2File download="file.zip" download_key="true" inline="true" /]">View PDF</a>

Extra Detail On Function Parameters

Parameter $config (array Required). This should be an array with one or more of the following elements.

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.

Since:

110926

Parameters:

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.

Returns:

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.

See Also:

s2Member\API_Functionss2member_file_download_key()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2163

s2member_last_login_time()

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.

Code Sample Using Function Parameters
  1. <?php
  2. if(s2member_last_login_time() <= strtotime("-30 days"))
  3. echo 'The current User last logged-in over 30 days ago.';
  4. else if(s2member_last_login_time(123) <= strtotime("-30 days"))
  5. echo 'User with ID #123 last logged-in over 30 days ago.';
  6. ?>
Shortcode Equivalent
  1. [s2Get user_option="s2member_last_login_time" /] # Last Login Time.

Since:

130210

Parameters:

int $user_id - Optional. Defaults to the current User's ID.

Returns:

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.

See Also:

s2Member\API_Functionsget_user_field()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2695

s2member_login_ips_for()

public array s2member_login_ips_for (str $username)

Gets login IPs for a particular username.

PHP Code Samples
  1. <?php print_r($ips = s2member_login_ips_for("johndoe22")); ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this (yet).

Since:

120728

Parameters:

str $username - A username.

Returns:

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.

Todo:

Create a Shortcode equivalent for this function.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2243

s2member_paid_registration_time()

public int s2member_paid_registration_time (str $level, int $user_id)

Retrieves a Paid Registration Time for the current User, and/or for a particular User.

NOTE A Paid Registration Time, is NOT necessarily related specifically to a Payment. s2Member records a Paid Registration Time, anytime a User acquires paid Membership Level Access.

In other words, if you create a new User inside your Dashboard at a Membership Level greater than Level #0, s2Member will record a Paid Registration Time immediately, because Membership Levels > 0, are reserved for paying Members. s2Member monitors changes to all User accounts, and records the first Paid Registration Time for each Member, at each paid Membership Level. So, s2Member stores the first Time a Member reaches each Level of paid access; and s2Member does NOT care if they actually paid, or not.

Code Sample Using Function Parameters
  1. <?php
  2. $time = s2member_registration_time (); # first registration time (free or otherwise).
  3. $time = s2member_paid_registration_time (); # first "paid" registration and/or upgrade time.
  4. $time = s2member_paid_registration_time ("level1"); # first "paid" registration or upgrade time at Level#1.
  5. $time = s2member_paid_registration_time ("level2"); # first "paid" registration or upgrade time at Level#2.
  6. $time = s2member_paid_registration_time ("level3"); # first "paid" registration or upgrade time at Level#3.
  7. $time = s2member_paid_registration_time ("level4"); # first "paid" registration or upgrade time at Level#4.
  8. ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this (yet).

Since:

3.5

Parameters:

str $level - Optional. Defaults to the first/initial Paid Registration Time, regardless of Level#.

int $user_id - Optional. Defaults to the current User's ID.

Returns:

int - A Unix Timestamp.

See Also:

s2Member\API_Functionsget_user_field()

[ back to top ]

pro\s2member-pro\includes\functions\separates\gateways\authnet\authnet-api-functions.inc.php at line #52

s2member_pro_authnet_s2p_v_query_ok()

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"])){ }

Since:

1.5

Parameters:

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.

Returns:

bool - True if the query string is OK/verified, else false.

[ back to top ]

pro\s2member-pro\includes\functions\api-functions.inc.php at line #104

s2member_pro_login_widget()

public str s2member_pro_login_widget (array $options, array $args)

Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file.

This function will return the HTML output from the widget function call. Example usage: <?php echo s2member_pro_login_widget(); ?>

The $options parameter (array) is completely optional (i.e. NOT required). It can be passed in as an array of options; overriding some or all of these defaults:

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:

Since:

1.5

Parameters:

array $options - Optional. See function description for details.

array $args - Optional. See function description for details.

Returns:

str - The Pro Login Widget, HTML markup.

[ back to top ]

pro\s2member-pro\includes\functions\api-functions.inc.php at line #214

s2member_pro_payflow_rbp_for_user()

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.

Since:

130405

Parameters:

str|int $user_id - Optional. A specific User ID. Defaults to the current User ID that is logged into the site.

Returns:

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.

[ back to top ]

pro\s2member-pro\includes\functions\api-functions.inc.php at line #252

s2member_pro_payflow_rbp_times_for_user()

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).

Since:

130405

Parameters:

str|int $user_id - Optional. A specific User ID. Defaults to the current User ID that is logged into the site.

Returns:

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.

[ back to top ]

pro\s2member-pro\includes\functions\api-functions.inc.php at line #137

s2member_pro_paypal_rbp_for_user()

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.

Since:

130405

Parameters:

str|int $user_id - Optional. A specific User ID. Defaults to the current User ID that is logged into the site.

Returns:

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.

Note:

If your PayPal® Pro account uses the Payflow™ Edition API, please use s2member_pro_payflow_rbp_for_user() instead.

[ back to top ]

pro\s2member-pro\includes\functions\api-functions.inc.php at line #177

s2member_pro_paypal_rbp_times_for_user()

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).

Since:

130405

Parameters:

str|int $user_id - Optional. A specific User ID. Defaults to the current User ID that is logged into the site.

Returns:

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.

Note:

If your PayPal® Pro account uses the Payflow™ Edition API, please use s2member_pro_payflow_rbp_times_for_user() instead.

[ back to top ]

pro\s2member-pro\includes\functions\separates\gateways\paypal\paypal-api-functions.inc.php at line #52

s2member_pro_paypal_s2p_v_query_ok()

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"])){ }

Since:

1.5

Parameters:

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.

Returns:

bool - True if the query string is OK/verified, else false.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2200

s2member_registration_time()

public int s2member_registration_time (int $user_id)

Obtains the Registration Time for the current User, and/or for a particular User.

The Registration Time, is the time at which the Username was created for the account, that's it. There's nothing special about this. This simply returns a Unix Timestamp.

Code Sample Using Function Parameters
  1. <?php
  2. if(s2member_registration_time() <= strtotime("-30 days"))
  3. echo 'The current User has existed for at least 30 days.';
  4. else if(s2member_registration_time(123) <= strtotime("-30 days"))
  5. echo 'User with ID #123 has existed for at least 30 days.';
  6. ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this (yet).

Since:

3.5

Parameters:

int $user_id - Optional. Defaults to the current User's ID.

Returns:

int - A Unix Timestamp. The Registration Time, is the time at which the Username was created for the account, that's it.

See Also:

s2Member\API_Functionsget_user_field()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2529

s2member_shorten_url()

public str|bool s2member_shorten_url (str $url, str $api_sp, bool $try_backups)

Shortens a long URL, based on s2Member configuration.

PHP Code Samples
  1. <?php echo s2member_shorten_url("http://www.example.com/a-long-url/"); ?>
  2. <?php echo s2member_shorten_url("http://www.example.com/a-long-url/", "tiny_url"); ?>
  3. <?php echo s2member_shorten_url("http://www.example.com/a-long-url/", "goo_gl"); ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this (yet).

Since:

111004

Parameters:

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.

Returns:

str|bool - The shortened URL on success, else false on failure.

Todo:

Create a Shortcode equivalent for this function.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2073

s2member_total_downloads_of()

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.

PHP Code Samples
  1. 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).
  2. 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).
  3. 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).
  4. 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).
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this yet.

Since:

111026

Parameters:

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.

Returns:

int - The total for this particular $file, based on configuration of function arguments.

Note:

Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.

See Also:

s2Member\API_Functionss2member_user_downloads()

s2Member\API_Functionss2member_total_unique_downloads_of()

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL

s2Member\API_ConstantsS2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED

s2Member\API_ConstantsS2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS

Todo:

Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.

Create a Shortcode equivalent.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2125

s2member_total_unique_downloads_of()

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.

PHP Code Samples
  1. 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).
  2. 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).
  3. 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).
  4. 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).
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this yet.

Since:

111026

Parameters:

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.

Returns:

int - The total for this particular $file, based on configuration of function arguments.

Note:

Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.

See Also:

s2Member\API_Functionss2member_user_downloads()

s2Member\API_Functionss2member_total_downloads_of()

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL

s2Member\API_ConstantsS2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED

s2Member\API_ConstantsS2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS

Todo:

Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.

Create a Shortcode equivalent.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2020

s2member_user_downloads()

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 Code Samples
  1. <?php
  2. $user_downloads = s2member_user_downloads();
  3. $specific_user_downloads = s2member_user_downloads(($user_id = 123));
  4. ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this yet.

Since:

111026

Parameters:

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).

Returns:

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.

Note:

Calculations returned by this function do NOT include File Downloads that were accessed with an Advanced File Download Key.

See Also:

s2Member\API_Functionss2member_total_downloads_of()

s2Member\API_Functionss2member_total_unique_downloads_of()

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS

s2Member\API_ConstantsS2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL

s2Member\API_ConstantsS2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED

s2Member\API_ConstantsS2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS

s2Member\API_ConstantsS2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS

Todo:

Make it possible for s2Member to keep a count of files downloaded with an Advanced Download Key.

Create a Shortcode equivalent.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2498

s2member_value_for_pp_inv()

public str s2member_value_for_pp_inv ()

Can be used to auto-fill the invoice for PayPal® Button Codes, with a unique Code~IP combination.

PHP Code Sample
  1. <?php echo s2member_value_for_pp_inv(); ?>
Shortcode & JavaScript Equivalents
  1. [s2Get constant="S2MEMBER_VALUE_FOR_PP_INV" /]
  2. <script type="text/javascript">
  3. document.write(s2member_value_for_pp_inv_gen());
  4. </script>

Since:

110720

Returns:

str - A unique Invoice.

See Also:

s2Member\API_ConstantsS2MEMBER_VALUE_FOR_PP_INV

Todo:

Create a true Shortcode equivalent function.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2667

s2member_xdecrypt()

public str s2member_xdecrypt (str $base64, str $key)

Two-way XOR encryption/decryption, with a URL-safe base64 wrapper.

PHP Code Samples
  1. <?php $encrypted = s2member_xencrypt("hello"); ?>
  2. <?php $decrypted = s2member_xdecrypt($encrypted); ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this (yet).

Since:

111106

Parameters:

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().

Returns:

str - Decrypted string.

See Also:

s2Member\API_Functionss2member_xencrypt()

s2Member\API_Functionss2member_encrypt()

s2Member\API_Functionss2member_decrypt()

Todo:

Create a Shortcode equivalent for this function.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #2634

s2member_xencrypt()

public str s2member_xencrypt (str $string, str $key, bool $w_md5_cs)

Two-way XOR encryption/decryption, with a URL-safe base64 wrapper.

PHP Code Samples
  1. <?php $encrypted = s2member_xencrypt("hello"); ?>
  2. <?php $decrypted = s2member_xdecrypt($encrypted); ?>
Shortcode Equivalent
  1. There is NO Shortcode equivalent for this (yet).

Since:

111106

Parameters:

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).

Returns:

str - Encrypted string.

See Also:

s2Member\API_Functionss2member_xdecrypt()

s2Member\API_Functionss2member_encrypt()

s2Member\API_Functionss2member_decrypt()

Todo:

Create a Shortcode equivalent for this function.

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #609

user_cannot()

public bool user_cannot (int|str $id, str $capability)

Conditional to determine if a specific User does NOT have a specific Capability or Role.

Another function WordPress® Functionuser_can() already exists in the WordPress® core.

Code Sample Using Both Functions
  1. <?php
  2. if(user_can(123, "access_s2member_level0"))
  3. echo 'User ID# 123 CAN access content protected at Level #0.';
  4. else if(user_cannot(123, "access_s2member_level0"))
  5. echo 'User ID# 123 CANNOT access content at Level #0.';
  6. ?>
Shortcode Conditional Equivalent
  1. [s2If user_can(123, access_s2member_level0)]
  2. User ID# 123 CAN access content protected at Level #0.
  3. [/s2If]
  4. [s2If user_cannot(123, access_s2member_level0)]
  5. User ID# 123 CANNOT access content at Level #0.
  6. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

3.5

Parameters:

int|str $id - A numeric WordPress® User ID.

str $capability - A WordPress® Capability ID ( i.e. access_s2member_level[0-9]+, access_s2member_ccap_music ).

Returns:

bool - True if the specific User does NOT have the specified Capability or Role, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #132

user_is()

public bool user_is (int|str $id, str $role)

Conditional to determine if a specific User is/has a specific Role.

Another function WordPress® Functionuser_can() already exists in the WordPress® core.

Code Sample Using Both Functions
  1. <?php
  2. if(user_is(123, "subscriber"))
  3. echo 'User ID# 123 is a Free Subscriber at Level #0.';
  4. else if(user_is(123, "s2member_level1"))
  5. echo 'User ID# 123 is a Member at Level #1.';
  6. else if(user_can(123, "access_s2member_level2"))
  7. echo 'User ID# 123 has access to content protected at Level #2.';
  8. # But, (important) they could actually be a Level #3 or #4 Member;
  9. # because Membership Levels provide incremental access.
  10. ?>

Shortcode Conditional Equivalent
  1. [s2If user_is(123, subscriber)]
  2. User ID# 123 is a Free Subscriber at Level #0.
  3. [/s2If]
  4. [s2If user_is(123, s2member_level1)]
  5. User ID# 123 is a Member at Level #1.
  6. [/s2If]
  7. [s2If user_can(123, access_s2member_level2)]
  8. User ID# 123 has access to content protected at Level #2.
  9. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

110524RC

Parameters:

int|str $id - A numeric WordPress® User ID.

str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ).

Returns:

bool - True if the specific User is/has the specified Role, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

s2member\includes\functions\api-functions.inc.php at line #217

user_is_not()

public bool user_is_not (int|str $id, str $role)

Conditional to determine if a specific User is/does NOT have a specific Role.

Another function WordPress® Functionuser_can() already exists in the WordPress® core.

Code Sample Using Three Functions
  1. <?php
  2. if(user_is(123, "subscriber"))
  3. echo 'User ID# 123 is a Free Subscriber at Level #0.';
  4. else if(user_is(123, "s2member_level1"))
  5. echo 'User ID# 123 is a Member at Level #1.';
  6. else if(user_can(123, "access_s2member_level2") && user_is_not(123, "s2member_level2"))
  7. echo 'User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member.';
  8. # So, (important) they could actually be a Level #3 or #4 Member;
  9. # because Membership Levels provide incremental access.
  10. ?>
Shortcode Conditional Equivalent
  1. [s2If user_is(123, subscriber)]
  2. User ID# 123 is a Free Subscriber at Level #0.
  3. [/s2If]
  4. [s2If user_is(123, s2member_level1)]
  5. User ID# 123 is a Member at Level #1.
  6. [/s2If]
  7. [s2If user_can(123, access_s2member_level2) AND user_is_not(123, s2member_level2)]
  8. User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member.
  9. [/s2If]
but please note, else if() logic is not possible with [s2If /].

Membership Levels Provide Incremental Access

WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 (a Free Subscriber). WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member. All of their other Roles/Capabilities are left untouched.

Since:

110524RC

Parameters:

int|str $id - A numeric WordPress® User ID.

str $role - A WordPress® Role ID ( i.e. s2member_level[0-9]+, administrator, editor, author, contributor, subscriber ).

Returns:

bool - True if the specific User is/does NOT have the specified Role, else false.

See Also:

s2Member\API_Functionsuser_is()

s2Member\API_Functionsuser_is_not()

s2Member\API_Functionscurrent_user_is()

s2Member\API_Functionscurrent_user_is_not()

s2Member\API_Functionscurrent_user_is_for_blog()

s2Member\API_Functionscurrent_user_is_not_for_blog()

s2Member\API_Functionsuser_cannot()

s2Member\API_Functionscurrent_user_cannot()

s2Member\API_Functionscurrent_user_cannot_for_blog()

WordPress® Functionuser_can()

WordPress® Functioncurrent_user_can()

WordPress® Functioncurrent_user_can_for_blog()

[ back to top ]

Source Code Documentation


Function Summary | Function Detail