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 |
integer
string
User's ID or username
integer
Optional. 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 |
string
Capability name.
boolean
Whether 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 |
string
Role 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 |
string
integer
Capability or role name to search.
boolean
True, 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 |
string
Capability name.
remove_role(string $role)
since | 2.0.0 |
---|---|
access | public |
string
Role 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 |
string
Role name.
translate_level_to_cap(integer $level) : string
Prepends 'level_' to level number.
since | 2.0.0 |
---|---|
access | public |
integer
Level number, 1 to 10.
string
update_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 |