Class BP_User

Description

BackPress User class.

  • since: 2.0.0

Located in /includes/class.bp-user.php (line 11)


	
			
Variable Summary
array $allcaps
array $caps
string $cap_key
string $first_name
int $id
int $ID
string $last_name
array $roles
Method Summary
BP_User BP_User (int|string $id, [int $name = ''])
void add_cap (string $cap, [bool $grant = true])
void add_role (string $role)
void get_role_caps ()
bool has_cap (string|int $cap, int $post_id)
void remove_all_caps ()
void remove_cap (string $cap)
void remove_role (string $role)
void set_role (string $role)
string translate_level_to_cap (int $level)
void update_user ()
void _init_caps ()
Variables
array $allcaps = array() (line 77)

All capabilities the user has, including individual and role based.

  • since: 2.0.0
  • access: public
array $caps = array() (line 50)

The individual capabilities the user has been given.

  • since: 2.0.0
  • access: public
string $cap_key (line 59)

User metadata option name.

  • since: 2.0.0
  • access: public
string $first_name = '' (line 88)

First name of the user.

Created to prevent notices.

  • since: 2.7.0
  • access: public
int $id = 0 (line 41)

The deprecated user's ID.

  • see: BP_User::$ID
  • deprecated: Use BP_User::$ID
  • since: 2.0.0
  • access: public
int $ID = 0 (line 30)

The user's ID.

  • since: 2.1.0
  • access: public
string $last_name = '' (line 99)

Last name of the user.

Created to prevent notices.

  • since: 2.7.0
  • access: public
array $roles = array() (line 68)

The roles the user is part of.

  • since: 2.0.0
  • access: public
Methods
Constructor BP_User (line 115)

PHP4 Constructor - Sets up the object properties.

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
BP_User BP_User (int|string $id, [int $name = ''])
  • int|string $id: User's ID or username
  • int $name: Optional. User's username
add_cap (line 317)

Add capability and grant or deny access to capability.

  • since: 2.0.0
  • access: public
void add_cap (string $cap, [bool $grant = true])
  • string $cap: Capability name.
  • bool $grant: Whether to grant capability to user.
add_role (line 203)

Add role to user.

Updates the user's meta data option with capabilities and roles.

  • since: 2.0.0
  • access: public
void add_role (string $role)
  • string $role: Role name.
get_role_caps (line 174)

Retrieve all of the role capabilities and merge with individual capabilities.

All of the capabilities of the roles the user belongs to are merged with the users individual roles. This also means that the user can be denied specific roles that their role might have, but the specific user isn't granted permission to.

  • since: 2.0.0
  • access: public
  • uses: $wp_roles
void get_role_caps ()
has_cap (line 363)

Whether user has capability or role name.

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.

  • return: True, if user has capability; false, if user does not have capability.
  • since: 2.0.0
  • access: public
bool has_cap (string|int $cap, int $post_id)
  • string|int $cap: Capability or role name to search.
  • int $post_id: Optional. Post ID to check capability against specific post.
remove_all_caps (line 342)

Remove all of the capabilities of the user.

  • since: 2.1.0
  • access: public
void remove_all_caps ()
remove_cap (line 330)

Remove capability from user.

  • since: 2.0.0
  • access: public
void remove_cap (string $cap)
  • string $cap: Capability name.
remove_role (line 216)

Remove role from user.

  • since: 2.0.0
  • access: public
void remove_role (string $role)
  • string $role: Role name.
set_role (line 235)

Set the role of the user.

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
void set_role (string $role)
  • string $role: Role name.
translate_level_to_cap (line 394)

Convert numeric level to level capability name.

Prepends 'level_' to level number.

  • since: 2.0.0
  • access: public
string translate_level_to_cap (int $level)
  • int $level: Level number, 1 to 10.
update_user (line 247)
void update_user ()
_init_caps (line 153)

Setup capability object properties.

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
void _init_caps ()

Documentation generated on Fri, 18 May 2012 01:33:41 +0100 by phpDocumentor 1.4.3