Source Code Documentation


Package s2Member\API_Functions ( Summary )


Easy API Functions for site owners to use in their own projects.

See Also:
full description ( below )
( 48 Functions )
Function Summary
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.
current_user_cannot()
Conditional to determine if the current User does NOT have a specific Capability or Role.
current_user_cannot_for_blog()
Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network.
current_user_is()
Conditional to determine if the current User is/has a specific Role.
current_user_is_for_blog()
Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network.
current_user_is_not()
Conditional to determine if the current User is/does NOT have a specific Role.
current_user_is_not_for_blog()
Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network.
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.
get_s2member_custom_fields()
Custom Registration/Profile Field configuration.
get_user_field()
A powerful function that can retrieve almost anything you need to know about the current User, and/or a particular User.
is_category_permitted_by_s2member()
Conditional to determine if a specific Category is permitted by s2Member, with consideration given to the current User's Role/Capabilites.
is_category_protected_by_s2member()
Conditional to determine if a specific Category is protected by s2Member; without considering the current User's Role/Capabilites.
is_page_permitted_by_s2member()
Conditional to determine if a specific Page is permitted by s2Member, with consideration given to the current User's Role/Capabilites.
is_page_protected_by_s2member()
Conditional to determine if a specific Page is protected by s2Member; without considering the current User's Role/Capabilites.
is_permitted_by_s2member()
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.
is_post_permitted_by_s2member()
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.
is_post_protected_by_s2member()
Conditional to determine if a specific Post (or Custom Post Type) is protected by s2Member; without considering the current User's Role/Capabilites.
is_protected_by_s2member()
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.
is_tag_permitted_by_s2member()
Conditional to determine if a specific Tag is permitted by s2Member, with consideration given to the current User's Role/Capabilites.
is_tag_protected_by_s2member()
Conditional to determine if a specific Tag is protected by s2Member; without considering the current User's Role/Capabilites.
is_uri_permitted_by_s2member()
Conditional to determine if a specific URI or URL is permitted by s2Member, with consideration given to the current User's Role/Capabilites.
is_uri_protected_by_s2member()
Conditional to determine if a specific URI or URL is protected by s2Member; without considering the current User's Role/Capabilities.
is_user_not_logged_in()
Conditional to determine if the current User is NOT logged in.
s2member_decrypt()
Two-way RIJNDAEL 256 encryption/decryption, with a URL-safe base64 wrapper.
s2member_encrypt()
Two-way RIJNDAEL 256 encryption/decryption, with a URL-safe base64 wrapper.
s2member_file_download_key()
Generates a File Download Key that provides access to a File protected by s2Member.
s2member_file_download_url()
Generates a File Download URL that provides access to a File protected by s2Member.
s2member_last_login_time()
Obtains the Last Login Time for the current User, and/or for a particular User.
s2member_login_ips_for()
Gets login IPs for a particular username.
s2member_paid_registration_time()
Retrieves a Paid Registration Time for the current User, and/or for a particular User.
s2member_pro_authnet_s2p_v_query_ok()
Verifies s2p-v in a given query string argument; from a custom URL for success.
s2member_pro_login_widget()
Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file.
s2member_pro_payflow_rbp_for_user()
Pulls an array of details from PayPal® Pro (Payflow™ Edition) API; related to a customer's Recurring Billing Profile.
s2member_pro_payflow_rbp_times_for_user()
Pulls last/next billing times from the PayPal® Pro (Payflow™ Edition) API; associated with a customer's Recurring Billing Profile.
s2member_pro_paypal_rbp_for_user()
Pulls an array of details from the PayPal® Pro API; related to a customer's Recurring Billing Profile.
s2member_pro_paypal_rbp_times_for_user()
Pulls last/next billing times from the PayPal® Pro API; associated with a customer's Recurring Billing Profile.
s2member_pro_paypal_s2p_v_query_ok()
Verifies s2p-v in a given query string argument; from a custom URL for success.
s2member_registration_time()
Obtains the Registration Time for the current User, and/or for a particular User.
s2member_shorten_url()
Shortens a long URL, based on s2Member configuration.
s2member_total_downloads_of()
Total downloads of a particular file; possibly by a particular User.
s2member_total_unique_downloads_of()
Total unique downloads of a particular file; possibly by a particular User.
s2member_user_downloads()
Retrieves an array of details, related to a User's File Downloads.
s2member_value_for_pp_inv()
Can be used to auto-fill the invoice for PayPal® Button Codes, with a unique Code~IP combination.
s2member_xdecrypt()
Two-way XOR encryption/decryption, with a URL-safe base64 wrapper.
s2member_xencrypt()
Two-way XOR encryption/decryption, with a URL-safe base64 wrapper.
user_cannot()
Conditional to determine if a specific User does NOT have a specific Capability or Role.
user_is()
Conditional to determine if a specific User is/has a specific Role.
user_is_not()
Conditional to determine if a specific User is/does NOT have a specific Role.

Easy API Functions for site owners to use in their own projects.

These are PHP Functions designed specifically for site owners and developers. They make it easy to integrate s2Member® with themes and other plugins. Everything from permissions, to details about each User; and even utility functions, are all included in this package.

We recommend using these s2Member\API_Functions, s2Member\API_Constants, or Hooks/Filters (over 1000 spread throughout all packages) to complete an advanced integration with s2Member®. Please try to refrain from using other internal classes/methods/constants whenever possible; as those are subject to change from one release to the next. Conversely, the availability of API Functions, API Constants, and Hooks/Filters will remain from one version to another. Only in rare circumstances would we ever remove one of these key elements; and if we do, backward compatibility would always remain when the previous version is deprecated for whatever reason.

Many of these API Functions are designed to supplement existing core functionality that comes with WordPress®. For instance, these WordPress® functions are also very useful, and notes to this effect are spread throughout the documentation here.

See Also: s2Member\API_Constants


Hacking s2Member (it's easy with Hooks/Filters for WordPress®)

If you need to add custom processing routines, or modify the behavior of existing processing routines; please use s2Member's Hooks/Filters for WordPress®. Hooks & Filters, give you the ability to "hook into", and/or "filter" processing routines, with files/functions of your own; instead of editing the s2Member® plugin files directly. This way you won't need to merge your changes/tweaks each time a new version of s2Member® is released. To create custom processing routines, place those routines into a PHP file here: /wp-content/mu-plugins/s2-hacks.php. If you don't have an /mu-plugins/ directory, please create one. These are (mu) MUST USE plugins, which are loaded into WordPress® automatically; that's what you want! If you're not familiar with Hooks/Filters for WordPress®, please read this article in the WordPress® Codex.

Adding a Hook (inside /wp-content/mu-plugins/s2-hacks.php)

Please make sure there are NO blank lines in your PHP file. Do NOT introduce spaces/tabs/lines before or after the <?php ?> tags.

  1. <?php
  2. add_action("hook_name", "my_action_hook_function");
  3. function my_action_hook_function($vars = array())
  4. {
  5. echo "My Hook works.";</p><p> # Optional. s2Member® passes you an array of defined variables.
  6. # print_r($vars); # Would give you a list of defined variables.
  7. # These are PHP variables defined within the scope of the Hook,
  8. # at the precise point in which the Hook is fired by s2Member®.</p><p> # $vars["__refs"] are also included (with some Hooks).
  9. # These are internal PHP variable references (very useful).
  10. # To learn all about references, please see PHP documentation:
  11. # http://www.php.net/manual/en/language.references.pass.php
  12. }
  13. ?>

Adding a Filter (inside /wp-content/mu-plugins/s2-hacks.php)

Please make sure there are NO blank lines in your PHP file. Do NOT introduce spaces/tabs/lines before or after the <?php ?> tags.

  1. <?php
  2. add_filter("filter_name", "my_filtering_function", 10, 2);
  3. function my_filtering_function($original_value, $vars = array())
  4. {
  5. if($original_value !== "something I like")
  6. return ($my_custom_value = "My Filter works.");</p><p> else # Return original value.
  7. return $original_value;</p><p> # Optional. s2Member® passes you an array of defined variables.
  8. # print_r($vars); # Would give you a list of defined variables.
  9. # These are PHP variables defined within the scope of the Filter,
  10. # at the precise point in which the Filter is fired by s2Member®.</p><p> # $vars["__refs"] are also included (with some Filters).
  11. # These are internal PHP variable references (very useful).
  12. # To learn all about references, please see PHP documentation:
  13. # http://www.php.net/manual/en/language.references.pass.php
  14. }
  15. ?>


Source Code Documentation