函数原型
map_meta_cap( string $cap, int $user_id, mixed $args ): string[]
函数描述
Maps a capability to the primitive capabilities required of the given user to satisfy the capability being checked.
是否弃用
未弃用
函数参数
-
$cap
string
Required - Capability being checked.
-
$user_id
int
Required - User ID.
-
$args
mixed
Optional - further parameters, typically starting with an object ID.
函数返回值
string[] Primitive capabilities required of the user.
函数位置
File: wp-includes/capabilities.php.
函数源码
map_meta_cap( 'edit_posts', $user->ID );
map_meta_cap( 'edit_post', $user->ID, $post->ID );
map_meta_cap( 'edit_post_meta', $user->ID, $post->ID, $meta_key );源码链接
变更日志
| Version | Description |
|---|---|
| 5.7.0 | Added the create_app_password, list_app_passwords, read_app_password, edit_app_password, delete_app_passwords, delete_app_password, and update_https capabilities. |
| 5.3.0 | Formalized the existing and already documented ...$args parameter by adding it to the function signature. |
| 5.2.0 | Added the resume_plugin and resume_theme capabilities. |
| 5.1.0 | Added the update_php capability. |
| 4.9.6 | Added the export_others_personal_data, erase_others_personal_data, and manage_privacy_options capabilities. |
| 2.0.0 | Introduced. |

