Wordpress PHP API

PHP API for theme and plugin developers

The following PHP functions are available for use and will continue to work the same way for backwards compatiblity. If you wish to use any other functions or variables from the Supporting Cast plugin, please let us know.

Check if a user is logged in

/**
* Check if the current user is logged in and has a valid account.
*
* @return bool
*/

public static function isLoggedIn():bool

Example

if (Supportingcast\ScUser::isLoggedIn()) { doSomething(); }

if (!Supportingcast\ScUser::isLoggedIn()) { denyAccess(); }

Check if a user has a specific plan

/**
* Check if the current user has the given plan or list of plans
*
* @param int|string|array $planIds - a plan id, a comma separated list of plan ids, or an array of plan ids
*
* @return bool
*/

public function hasPlan($planIds): bool

Example


if (Supportingcast\ScUser::current()->hasPlan(1)) { doSomething(); }

if (Supportingcast\ScUser::current()->hasPlan("1,2,3")) { doSomething(); }

if (Supportingcast\ScUser::current()->hasPlan([1,2,3])) { doSomething(); }

Check if a user owns a product

/**
* Check if the current user has the given product or list of products
*
* @param int|string|array $productIds - a product id, a comma separated list of product ids, or an array of product ids
* @param false $requireAll - by default any match will return true; if you set $requireAll to true, all
productIds must be owned by the user
*
* @return bool
*/

public function hasProducts($productIds, $requireAll = false): bool

Example


if (Supportingcast\ScUser::current()->hasProducts("1,2,3")) { doSomething(); }

if (Supportingcast\ScUser::current()->hasProducts([1,2,3], true)) { doSomething(); }