首页 WordPress函数大全 map_meta_cap()

map_meta_cap()

2020-05-02 / 5514阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

map_meta_cap( string $cap, int $user_id, mixed $args )

将元功能映射到原始功能。

描述

如果功能是元功能,则此函数还接受要映射的对象的ID。元功能(例如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);  

实际上,这并没有比较用户ID是否具有实际功能,即功能是什么。元功能列表值可以是“ delete_user”,“ edit_user”,“ remove_user”,“ promote_user”,“ delete_post”,“ delete_page”,“ edit_post”,“ edit_page”,“ read_post”或“ read_page”。

参数

$cap

(string)
(Required)
Capability name.

$user_id

(int)
(Required)
User ID.

$args

(mixed)
(Optional)
further parameters, typically starting with an object ID.

返回

(string[]) Actual capabilities for meta capability.

大家谈论
    我的见解