[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> capabilities.php (summary)

Core User Role & Capabilities API

File Size: 952 lines (30 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 14 functions

  map_meta_cap()
  current_user_can()
  current_user_can_for_blog()
  author_can()
  user_can()
  wp_roles()
  get_role()
  add_role()
  remove_role()
  get_super_admins()
  is_super_admin()
  grant_super_admin()
  revoke_super_admin()
  wp_maybe_grant_install_languages_cap()

Functions
Functions that are not part of a class:

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'.

return: array Actual capabilities for meta capability.
param: string $cap       Capability name.
param: int    $user_id   User ID.
param: int    $object_id Optional. ID of the specific object to check against if `$cap` is a "meta" cap.

current_user_can( $capability )   X-Ref
Whether the current user has a specific capability.

While checking against particular roles in place of a capability is supported
in part, this practice is discouraged as it may produce unreliable results.

Note: Will always return true if the current user is a super admin, unless specifically denied.

return: bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
param: string $capability Capability name.
param: int    $object_id  Optional. ID of the specific object to check against if `$capability` is a "meta" cap.

current_user_can_for_blog( $blog_id, $capability )   X-Ref
Whether the current user has a specific capability for a given site.

return: bool Whether the user has the given capability.
param: int    $blog_id    Site ID.
param: string $capability Capability name.

author_can( $post, $capability )   X-Ref
Whether the author of the supplied post has a specific capability.

return: bool Whether the post author has the given capability.
param: int|WP_Post $post       Post ID or post object.
param: string      $capability Capability name.

user_can( $user, $capability )   X-Ref
Whether a particular user has a specific capability.

return: bool Whether the user has the given capability.
param: int|WP_User $user       User ID or object.
param: string      $capability Capability name.

wp_roles()   X-Ref
Retrieves the global WP_Roles instance and instantiates it if necessary.

return: WP_Roles WP_Roles global instance if not already instantiated.

get_role( $role )   X-Ref
Retrieve role object.

return: WP_Role|null WP_Role object if found, null if the role does not exist.
param: string $role Role name.

add_role( $role, $display_name, $capabilities = array()   X-Ref
Add role, if it does not exist.

return: WP_Role|null WP_Role object if role is added, null if already exists.
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 );

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.

return: bool True if the user is a site admin.
param: int $user_id (Optional) The ID of a user. Defaults to the current user.

grant_super_admin( $user_id )   X-Ref
Grants Super Admin privileges.

return: bool True on success, false on failure. This can fail when the user is
param: int $user_id ID of the user to be granted Super Admin privileges.

revoke_super_admin( $user_id )   X-Ref
Revokes Super Admin privileges.

return: bool True on success, false on failure. This can fail when the user's email
param: int $user_id ID of the user Super Admin privileges to be revoked from.

wp_maybe_grant_install_languages_cap( $allcaps )   X-Ref
Filters the user capabilities to grant the 'install_languages' capability as necessary.

A user must have at least one out of the 'update_core', 'install_plugins', and
'install_themes' capabilities to qualify for 'install_languages'.

return: bool[] Filtered array of the user's capabilities.
param: bool[] $allcaps An array of all the user's capabilities.



Generated: Wed Dec 19 08:20:01 2018 Cross-referenced by PHPXref 0.7