[ Index ] |
WordPress Cross Reference |
[Source view] [Print] [Project Stats]
WordPress Roles and Capabilities.
File Size: | 1528 lines (38 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
WP_Roles:: (10 methods):
__construct()
_init()
reinit()
add_role()
remove_role()
add_cap()
remove_cap()
get_role()
get_names()
is_role()
WP_Role:: (4 methods):
__construct()
add_cap()
remove_cap()
has_cap()
WP_User:: (33 methods):
__construct()
init()
get_data_by()
__isset()
__get()
__set()
exists()
get()
has_prop()
to_array()
_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()
for_blog()
map_meta_cap()
current_user_can()
current_user_can_for_blog()
author_can()
user_can()
get_role()
add_role()
remove_role()
get_super_admins()
is_super_admin()
__construct() X-Ref |
Constructor |
_init() X-Ref |
Set up 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. |
reinit() X-Ref |
Reinitialize the object Recreates the role objects. This is typically called only by switch_to_blog() after switching wpdb to a new blog ID. |
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: WP_Role|null 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: WP_Role|null WP_Role object if found, null if the role does not exist. |
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 |
__construct( $role, $capabilities ) X-Ref |
Constructor - Set up 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. param: string $role Role name. param: array $capabilities List of capabilities. |
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. |
__construct( $id = 0, $name = '', $blog_id = '' ) X-Ref |
Constructor Retrieves the userdata and passes it to {@link WP_User::init()}. param: int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. param: string $name Optional. User's username param: int $blog_id Optional Blog ID, defaults to current blog. return: WP_User |
init( $data, $blog_id = '' ) X-Ref |
Sets up object properties, including capabilities. param: object $data User DB row object param: int $blog_id Optional. The blog id to initialize for |
get_data_by( $field, $value ) X-Ref |
Return only the main user fields param: string $field The field to query against: 'id', 'slug', 'email' or 'login' param: string|int $value The field value return: object Raw user object |
__isset( $key ) X-Ref |
Magic method for checking the existence of a certain custom field |
__get( $key ) X-Ref |
Magic method for accessing custom fields |
__set( $key, $value ) X-Ref |
Magic method for setting custom fields |
exists() X-Ref |
Determine whether the user exists in the database. return: bool True if user exists in the database, false if not. |
get( $key ) X-Ref |
Retrieve the value of a property or meta key. Retrieves from the users and usermeta table. param: string $key Property |
has_prop( $key ) X-Ref |
Determine whether a property or meta key is set Consults the users and usermeta tables. param: string $key Property |
to_array() X-Ref |
Return an array representation. return: array Array representation. |
_init_caps( $cap_key = '' ) X-Ref |
Set up 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. param: string $cap_key Optional capability key |
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. return: array List of all capabilities for the user. |
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 specific object, such as a post or user. param: string|int $cap Capability or role name to search. 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 |
for_blog( $blog_id = '' ) X-Ref |
Set the blog to operate on. Defaults to the current blog. param: int $blog_id Optional Blog ID, defaults to current blog. |
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', 'remove_user', 'promote_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 |
current_user_can_for_blog( $blog_id, $capability ) X-Ref |
Whether current user has a capability or role for a given blog. param: int $blog_id Blog ID 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 |
user_can( $user, $capability ) X-Ref |
Whether a particular user has capability or role. param: int|object $user User ID or object. param: string $capability Capability or role name. return: bool |
get_role( $role ) X-Ref |
Retrieve role object. param: string $role Role name. return: WP_Role|null WP_Role object if found, null if the role does not exist. |
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, e.g. array( 'edit_posts' => true, 'delete_posts' => false ); return: WP_Role|null 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. |
get_super_admins() X-Ref |
Retrieve a list of super admins. return: array List of super admin logins |
is_super_admin( $user_id = false ) X-Ref |
Determine if user is a site admin. param: int $user_id (Optional) The ID of a user. Defaults to the current user. return: bool True if the user is a site admin. |
Generated: Tue Mar 25 01:41:18 2014 | WordPress honlapkészítés: online1.hu |