PHP Class WPAS_Member

Since: 3.3
显示文件 Open project: awesome-support/awesome-support Class Usage Examples

Public Properties

Property Type Description
$caps array User capabilities
$data array User profile data
$is_member boolean Whether or not the user requested is a member of Awesome Support
$roles array User roles
$user_id integer User ID

Public Methods

Method Description
__construct ( integer | stdClass $user ) WPAS_Member constructor.
has_cap ( string $cap ) : boolean Check if the user has a specific capability
is_member ( ) : boolean Check if the current user actually is an Awesome Support member

Protected Methods

Method Description
data_defaults ( ) : array Get the default profile data fields
get_user_data ( $user_id ) : array Get user data by user ID
init ( $data ) : void Setup the user data
setup_caps ( ) : void Setup the user capabilities based on their roles
setup_roles ( ) : void Setup the user roles

Method Details

__construct() public method

WPAS_Member constructor.
public __construct ( integer | stdClass $user )
$user integer | stdClass The user ID or stdClass

data_defaults() protected method

This is also used as a whitelist. Only fields listed in the defaults will be actually used as the user $data
Since: 3.3
protected data_defaults ( ) : array
return array

get_user_data() protected method

Get user data by user ID
Since: 3.3
protected get_user_data ( $user_id ) : array
$user_id
return array

has_cap() public method

Check if the user has a specific capability
Since: 3.3
public has_cap ( string $cap ) : boolean
$cap string Capability to check
return boolean

init() protected method

Setup the user data
Since: 3.3
protected init ( $data ) : void
$data
return void

is_member() public method

Check if the current user actually is an Awesome Support member
Since: 3.3
public is_member ( ) : boolean
return boolean

setup_caps() protected method

This method is mostly based on WordPress' WP_User::get_role_caps()
Since: 3.3
protected setup_caps ( ) : void
return void

setup_roles() protected method

Setup the user roles
Since: 3.3
protected setup_roles ( ) : void
return void

Property Details

$caps public_oe property

User capabilities
Since: 3.3
public array $caps
return array

$data public_oe property

User profile data
Since: 3.3
public array $data
return array

$is_member public_oe property

Whether or not the user requested is a member of Awesome Support
Since: 3.3
public bool $is_member
return boolean

$roles public_oe property

User roles
Since: 3.3
public array $roles
return array

$user_id public_oe property

User ID
Since: 3.3
public int $user_id
return integer