Class Reference Archives - WordPress Membership Plugin - Membership Sites https://wishlistmember.com Quickly Protect Your Content With WishList Member Mon, 10 Dec 2012 19:21:58 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.2 https://wishlistmember.com/wp-content/uploads/2020/03/cropped-WishList-Member-logomark-32x32.png Class Reference Archives - WordPress Membership Plugin - Membership Sites https://wishlistmember.com 32 32 Class Reference: wlmapiclass https://wishlistmember.com/docs/class-reference-wlmapiclass/ Mon, 10 Dec 2012 19:21:58 +0000 http://wishlistproducts.com/codex/?p=245 The wlmapiclass handles external connections to the WishList Member API. It is the sister class for the WishListMemberAPIRequest() function included in WishList Member which handles all internal API requests. This class along with wlmapiclass.php and functions.php are already installed in the latest version of WishList Member. You do NOT need to include them in your plugin/theme if […]

The post Class Reference: wlmapiclass appeared first on WordPress Membership Plugin - Membership Sites.]]>
The wlmapiclass handles external connections to the WishList Member API. It is the sister class for the WishListMemberAPIRequest() function included in WishList Member which handles all internal API requests.

This class along with wlmapiclass.php and functions.php are already installed in the latest version of WishList Member. You do NOT need to include them in your plugin/theme if you have WishList Member installed on your site. Simply begin calling functions or using the class to get started.

Methods

__construct($url, $key, $tempdir=null)

Constructor method for the class. Sets these properties used throughout the class: wlmapiclass:url, wlmapiclass:key, and wlmapiclass:tempdir. wlmapiclass:url is optional and the class will create a /tmp directory in the current folder if this is not specified.

_request($method, $resource, $data = ”)

Private method that process all requests. It requires the method (GET, POST, PUT, DELETE) and the resource. If the resource/method combination requires input data, that will be required here; otherwise, it is ignored. This is simply and internal helper and can't be called directly outside of the class.

post($resource, $data)

Send a POST request to WishList Member API (add new data). Note that $data is required here.

get($resource, $data=”)

Send a GET request to WishList Member API (retrieve data). Note that $data is optional here.

put($resource, $data)

Send a PUT request to WishList Member API (update existing data). Note that $data is required here.

delete($resource, $data=”)

Send a DELETE request to WishList Member API (delete the resource). Note that $data is optional here.

_resourcefix($resource)

Fixes API requests that omit a trailing slash which is required by the API. It adds the slash, if necessary. This is a private function that cannot be called directly outside the class.

_auth()

Handles authentication with the WishList Member. This is a private function that cannot be called directly outside the class. Attempting to authenticate without accessing a resource will always return a “Not Authenticated” error.

Notes

This class is necessary for external API requests.

The post Class Reference: wlmapiclass appeared first on WordPress Membership Plugin - Membership Sites.]]>
Class Reference: WLMAPIMethods https://wishlistmember.com/docs/class-reference-wlmapimethods/ Mon, 10 Dec 2012 19:07:55 +0000 http://wishlistproducts.com/codex/?p=233 The WLMAPIMethods class is the service class for the helper functions in core/api-helper/functions.php. The class does all the work of connecting to the WishList Member API, authenticating, checking internal vs external connection, caching, and processing requests. The class defaults to connecting to the local WishList Member install. However, it can be used directly to connect […]

The post Class Reference: WLMAPIMethods appeared first on WordPress Membership Plugin - Membership Sites.]]>
The WLMAPIMethods class is the service class for the helper functions in core/api-helper/functions.php. The class does all the work of connecting to the WishList Member API, authenticating, checking internal vs external connection, caching, and processing requests.

The class defaults to connecting to the local WishList Member install. However, it can be used directly to connect to an external WishList Member site. Use of the class directly does require WordPress.

This class along with wlmapiclass.php and functions.php are already installed in the latest version of WishList Member. You do NOT need to include them in your plugin/theme if you have WishList Member installed on your site. Simply begin calling functions or using the class to get started.

Methods

__construct($cache_time = 3600, $url = false, $api_key = false)

Constructor method for the class. Auto-generates defaults when using the helper functions in core/api-helper/functions.php. When used directly, you can specify a $url and $api_key of an external site to connect to and use WishList Member data from that site.

getAPIkey($raw = false)

Gets the API key for the local site. Used primarily with the helper functions. $raw specifies if you want the cached version of this request or not (which is useful for testing).

loadAPI()

Connects to the API, authenticates, and preps the $api object for use. This method won't work if called directly. It will return a “Not Authenticated” error if called directly. It's used in the following methods to ease the loading of the API in requests.

get_levels($raw = false)

Returns an array of all the membership levels in the current install. $raw specifies if you want the cached version of this request or not (which is useful for testing).

get_level($level_id, $raw = false)

Returns an array of data for the specified membership level. $raw specifies if you want the cached version of this request or not (which is useful for testing).

create_level($args)

Creates a new level according to the specified arguments. See wlmapi_create_level for a list of accepted arguments.

update_level($level_id, $args)

Updates the specified level according to the specified arguments. See wlmapi_update_level for a list of accepted arguments.

delete_level($level_id)

Deletes the specified membership level.

get_level_members($level_id, $raw = false)

Retrieves an array list of all members in the specified membership level. $raw specifies if you want the cached version of this request or not (which is useful for testing).

add_member_to_level($level_id, $args)

Adds the specified user to the specified membership level. See wlmapi_add_member_to_level for a list of accepted arguments.

remove_member_from_level($level_id, $member_id)

Removes the specified member from the specified membership level.

get_level_member_data($level_id, $member_id, $raw = false)

Retrieves membership level information for an individual member. $raw specifies if you want the cached version of this request or not (which is useful for testing).

update_level_member_data($level_id, $member_id, $args)

Updates membership level information for an individual member. See wlmapi_update_level_member_data for a list of accepted arguments.

get_level_posts($level_id, $raw = false)

Retrieves an array list of all posts in a membership level. $raw specifies if you want the cached version of this request or not (which is useful for testing).

get_level_post_type($level_id, $post_type, $raw = false)

Retrieves an array list of all posts in a membership level of the specified post type. $raw specifies if you want the cached version of this request or not (which is useful for testing).

add_post_to_level($level_id, $args)

Adds a post to a membership level. See wlmapi_add_post_to_level for a list of accepted arguments.

remove_post_from_level($level_id, $post_id)

Removes a post from a membership level.

get_level_pages($level_id, $raw = false)

Retrieves an array list of all pages in a membership level. $raw specifies if you want the cached version of this request or not (which is useful for testing).

add_page_to_level($level_id, $args)

Adds a page to a membership level. See wlmapi_add_page_to_level for a list of accepted arguments.

remove_page_from_level($level_id, $page_id)

Removes a page from a membership level.

get_level_commented_posts($level_id, $raw = false)

Retrieves an array list of all posts with comments in a membership level. $raw specifies if you want the cached version of this request or not (which is useful for testing).

add_post_comments_to_level($level_id, $args)

Adds a post's comments to a membership level. See wlmapi_add_post_comments_to_level for a list of accepted arguments.

remove_post_comments_from_level($level_id, $post_id)

Removes a post's comments from a membership level.

get_level_categories($level_id, $raw = false)

Retrieves an array list of all categories in a membership level. $raw specifies if you want the cached version of this request or not (which is useful for testing).

add_category_to_level($level_id, $args)

Adds a category to a membership level. See wlmapi_add_category_to_level for a list of accepted arguments.

remove_category_from_level($level_id, $category_id)

Removes a category from a membership level.

get_protected_posts($raw = false)

Retrieves an array list of all posts that are protected. $raw specifies if you want the cached version of this request or not (which is useful for testing).

protect_post($args)

Protects a post. See wlmapi_protect_post for a list of accepted arguments.

unprotect_post($post_id)

Unprotects a post.

get_protected_pages($raw = false)

Retrieves an array list of all pages that are protected. $raw specifies if you want the cached version of this request or not (which is useful for testing).

protect_page($args)

Protects a page. See wlmapi_protect_page for a list of accepted arguments.

unprotect_page($page_id)

Un-protects a page.

get_protected_categories($raw = false)

Retrieves an array list of all categories that are protected. $raw specifies if you want the cached version of this request or not (which is useful for testing).

protect_category($args)

Protects a category. See wlmapi_protect_category for a list of accepted arguments.

unprotect_category($category_id)

Un-protects a category.

get_members($raw = false)

Retrieves an array list of all members from the database. $raw specifies if you want the cached version of this request or not (which is useful for testing).

add_member($args)

Adds a new member to the database. See wlmapi_add_member for a list of accepted arguments.

get_member($user_id, $raw = false)

Retrieves membership details for the specified member. $raw specifies if you want the cached version of this request or not (which is useful for testing).

get_member_levels($user_id, $raw = false)

Retrieves membership level details for the specified user.  $raw specifies if you want the cached version of this request or not (which is useful for testing).

update_member($user_id, $args)

Updates a member's details. See wlmapi_update_member for a list of accepted arguments.

delete_member($user_id)

Deletes a member from the database.

the_levels()

Filters the get_levels array list. Use the filter “wlmapi_the_levels” to filter the array.

the_level($level_id)

Filters the get_level array list. Use the filter “wlmapi_the_level” to filter the array.

the_level_members($level_id)

Filters the get_level_members array list. Use the filter “wlmapi_the_level_members” to filter the array.

the_level_posts($level_id)

Filters the get_level_posts array list. Use the filter “wlmapi_the_level_posts” to filter the array.

the_members()

Filters the get_members array list. Use the filter “wlmapi_the_members” to filter the array.

is_user_a_member($level_id, $user_id)

Checks if the user belongs to the membership level.

manage_post($level_id, $post_ids)

Protects posts and adds them to the membership level. $post_ids accepts an array or comma-seprated list of post IDs.

unmanage_post($level_id, $post_ids)

Un-protects posts and removes them from the membership level. $post_ids accepts an array or comma-seprated list of post IDs.

Notes

This class requires the wlmapiclass.php in order to work.

The post Class Reference: WLMAPIMethods appeared first on WordPress Membership Plugin - Membership Sites.]]>