| [ Index ] |
PHP Cross Reference of Wordpress 2.9.1 |
[Source view] [Print] [Project Stats]
WordPress Roles and Capabilities.
| File Size: | 1060 lines (26 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
WP_Roles:: (9 methods):
WP_Roles()
_init()
add_role()
remove_role()
add_cap()
remove_cap()
get_role()
get_names()
is_role()
WP_Role:: (4 methods):
WP_Role()
add_cap()
remove_cap()
has_cap()
WP_User:: (19 methods):
WP_User()
_init_caps()
get_role_caps()
add_role()
remove_role()
set_role()
level_reduction()
update_user_level_from_caps()
add_cap()
remove_cap()
remove_all_caps()
has_cap()
translate_level_to_cap()
map_meta_cap()
current_user_can()
author_can()
get_role()
add_role()
remove_role()
| WP_Roles() X-Ref |
| PHP4 Constructor - Call {@link WP_Roles::_init()} method. return: WP_Roles |
| _init() X-Ref |
| Setup the object properties. The role key is set to the current prefix for the $wpdb object with 'user_roles' appended. If the $wp_user_roles global is set, then it will be used and the role option will not be updated or used. |
| add_role( $role, $display_name, $capabilities = array() X-Ref |
| Add role name with capabilities to list. Updates the list of roles, if the role doesn't already exist. The capabilities are defined in the following format `array( 'read' => true );` To explicitly deny a role a capability you set the value for that capability to false. param: string $role Role name. param: string $display_name Role display name. param: array $capabilities List of role capabilities in the above format. return: null|WP_Role WP_Role object if role is added, null if already exists. |
| remove_role( $role ) X-Ref |
| Remove role by name. param: string $role Role name. |
| add_cap( $role, $cap, $grant = true ) X-Ref |
| Add capability to role. param: string $role Role name. param: string $cap Capability name. param: bool $grant Optional, default is true. Whether role is capable of performing capability. |
| remove_cap( $role, $cap ) X-Ref |
| Remove capability from role. param: string $role Role name. param: string $cap Capability name. |
| get_role( $role ) X-Ref |
| Retrieve role object by name. param: string $role Role name. return: object|null Null, if role does not exist. WP_Role object, if found. |
| get_names() X-Ref |
| Retrieve list of role names. return: array List of role names. |
| is_role( $role ) X-Ref |
| Whether role name is currently in the list of available roles. param: string $role Role name to look up. return: bool |
| WP_Role( $role, $capabilities ) X-Ref |
| PHP4 Constructor - Setup object properties. The list of capabilities, must have the key as the name of the capability and the value a boolean of whether it is granted to the role or not. param: string $role Role name. param: array $capabilities List of capabilities. return: WP_Role |
| add_cap( $cap, $grant = true ) X-Ref |
| Assign role a capability. param: string $cap Capability name. param: bool $grant Whether role has capability privilege. |
| remove_cap( $cap ) X-Ref |
| Remove capability from role. This is a container for {@link WP_Roles::remove_cap()} to remove the capability from the role. That is to say, that {@link WP_Roles::remove_cap()} implements the functionality, but it also makes sense to use this class, because you don't need to enter the role name. param: string $cap Capability name. |
| has_cap( $cap ) X-Ref |
| Whether role has capability. The capabilities is passed through the 'role_has_cap' filter. The first parameter for the hook is the list of capabilities the class has assigned. The second parameter is the capability name to look for. The third and final parameter for the hook is the role name. param: string $cap Capability name. return: bool True, if user has capability. False, if doesn't have capability. |
| WP_User( $id, $name = '' ) X-Ref |
| 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 {@link WP_User::_init_caps()} after setting up the object's user data properties. param: int|string $id User's ID or username param: int $name Optional. User's username return: WP_User |
| _init_caps() X-Ref |
| 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. |
| get_role_caps() X-Ref |
| 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. |
| add_role( $role ) X-Ref |
| Add role to user. Updates the user's meta data option with capabilities and roles. param: string $role Role name. |
| remove_role( $role ) X-Ref |
| Remove role from user. param: string $role Role name. |
| set_role( $role ) X-Ref |
| 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. param: string $role Role name. |
| level_reduction( $max, $item ) X-Ref |
| Choose the maximum level the user has. Will compare the level from the $item parameter against the $max parameter. If the item is incorrect, then just the $max parameter value will be returned. Used to get the max level based on the capabilities the user has. This is also based on roles, so if the user is assigned the Administrator role then the capability 'level_10' will exist and the user will get that value. param: int $max Max level of user. param: string $item Level capability name. return: int Max Level. |
| update_user_level_from_caps() X-Ref |
| Update the maximum user level for the user. Updates the 'user_level' user metadata (includes prefix that is the database table prefix) with the maximum user level. Gets the value from the all of the capabilities that the user has. |
| add_cap( $cap, $grant = true ) X-Ref |
| Add capability and grant or deny access to capability. param: string $cap Capability name. param: bool $grant Whether to grant capability to user. |
| remove_cap( $cap ) X-Ref |
| Remove capability from user. param: string $cap Capability name. |
| remove_all_caps() X-Ref |
| Remove all of the capabilities of the user. |
| has_cap( $cap ) X-Ref |
| 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. param: string|int $cap Capability or role name to search. param: int $post_id Optional. Post ID to check capability against specific post. return: bool True, if user has capability; false, if user does not have capability. |
| translate_level_to_cap( $level ) X-Ref |
| Convert numeric level to level capability name. Prepends 'level_' to level number. param: int $level Level number, 1 to 10. return: string |
| map_meta_cap( $cap, $user_id ) X-Ref |
| Map meta capabilities to primitive capabilities. This does not actually compare whether the user ID has the actual capability, just what the capability or capabilities are. Meta capability list value can be 'delete_user', 'edit_user', 'delete_post', 'delete_page', 'edit_post', 'edit_page', 'read_post', or 'read_page'. param: string $cap Capability name. param: int $user_id User ID. return: array Actual capabilities for meta capability. |
| current_user_can( $capability ) X-Ref |
| Whether current user has capability or role. param: string $capability Capability or role name. return: bool |
| author_can( $post, $capability ) X-Ref |
| Whether author of supplied post has capability or role. param: int|object $post Post ID or post object. param: string $capability Capability or role name. return: bool |
| get_role( $role ) X-Ref |
| Retrieve role object. param: string $role Role name. return: object |
| add_role( $role, $display_name, $capabilities = array() X-Ref |
| Add role, if it does not exist. param: string $role Role name. param: string $display_name Display name for role. param: array $capabilities List of capabilities. return: null|WP_Role WP_Role object if role is added, null if already exists. |
| remove_role( $role ) X-Ref |
| Remove role, if it exists. param: string $role Role name. return: null |
| Generated: Fri Jan 8 00:19:48 2010 | Cross-referenced by PHPXref 0.7 |