描述
如果能力是meta能力,则此函数还接受要映射的对象的ID。meta能力(如edit_post和edit_user)是此函数用来映射到用户或角色所需的基本能力(如,edit_posts或edit_others_posts)的能力。
示例用法:
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 );
此函数不检查用户是否具有所需的能力,只返回所需的能力。
参数
- $cap
-
(string)(必填) 被检查的能力。
- $user_id
-
(int)(必填) 用户ID。
- $args
-
(mixed)(可选) 其他参数,通常从对象ID开始。
返回
(string[]) 用户所需的基本功能。
源码
更新日志
| 版本 | 描述 |
|---|---|
| 5.7.0 | 添加了create_app_password、list_app_passwords、read_app_passwordedit_app_password、delete_app_passwords、delete_app_password和update_https能力。 |
| 5.3.0 | 通过将现有且已记录的...$args参数添加到函数签名中,将其形参化。 |
| 5.2.0 | 添加了resume_plugin和resume_theme能力。 |
| 5.1.0 | 添加了update_php能力。 |
| 4.9.6 | 添加了export_others_personal_data、erase_others_personal_data和manage_privacy_options能力。 |
| 2.0.0 | 开始引入 |