BackPress User class.
| since | 2.0.0 |
|---|---|
| package | BackPress |
| subpackage | User |
BP_User($id, $name = '')
__construct(integer|string $id, integer $name = '') : \BP_User
Retrieves the userdata and then assigns all of the data keys to direct properties of the object. Calls BP_User::_init_caps() after setting up the object's user data properties.
| since | 2.0.0 |
|---|---|
| access | public |
integerstringUser's ID or username
integerOptional. User's username
\BP_User_init_caps()
Will set the value for the 'cap_key' property to current database table prefix, followed by 'capabilities'. Will then check to see if the property matching the 'cap_key' exists and is an array. If so, it will be used.
| since | 2.1.0 |
|---|---|
| access | protected |
add_cap(string $cap, boolean $grant = true)
| since | 2.0.0 |
|---|---|
| access | public |
stringCapability name.
booleanWhether to grant capability to user.
add_role(string $role)
Updates the user's meta data option with capabilities and roles.
| since | 2.0.0 |
|---|---|
| access | public |
stringRole name.
get_role_caps()
has_cap(string|integer $cap) : boolean
This is useful for looking up whether the user has a specific role assigned to the user. The second optional parameter can also be used to check for capabilities against a specfic post.
| since | 2.0.0 |
|---|---|
| access | public |
stringintegerCapability or role name to search.
booleanTrue, if user has capability; false, if user does not have capability.remove_all_caps()
| since | 2.1.0 |
|---|---|
| access | public |
remove_cap(string $cap)
| since | 2.0.0 |
|---|---|
| access | public |
stringCapability name.
remove_role(string $role)
| since | 2.0.0 |
|---|---|
| access | public |
stringRole name.
set_role(string $role)
This will remove the previous roles of the user and assign the user the new one. You can set the role to an empty string and it will remove all of the roles from the user.
| since | 2.0.0 |
|---|---|
| access | public |
stringRole name.
translate_level_to_cap(integer $level) : string
Prepends 'level_' to level number.
| since | 2.0.0 |
|---|---|
| access | public |
integerLevel number, 1 to 10.
stringupdate_user()
$ID : integer
0| since | 2.1.0 |
|---|---|
| access | public |
$allcaps : array
array()| since | 2.0.0 |
|---|---|
| access | public |
$cap_key : string
| since | 2.0.0 |
|---|---|
| access | public |
$caps : array
array()| since | 2.0.0 |
|---|---|
| access | public |
$data : array
This will be set as properties of the object.
| since | 2.0.0 |
|---|---|
| access | private |
$first_name : string
''Created to prevent notices.
| since | 2.7.0 |
|---|---|
| access | public |
$id : integer
0$last_name : string
''Created to prevent notices.
| since | 2.7.0 |
|---|---|
| access | public |
$roles : array
array()| since | 2.0.0 |
|---|---|
| access | public |