Home › Types Community Support › [Resolved] Hide Custom Fields Group for specific user role only
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Hong_Kong (GMT+08:00)
This topic contains 1 reply, has 2 voices.
Last updated by Luo Yang 11 years, 2 months ago.
Assisted by: Luo Yang.
How can I reference Fields group and hide it only for users that have certain role?
Something like this...
function admin_only_metabox() { global $current_user; if($current_user->roles[0] == 'custom_role') { //HIDE SPECIFIC CUSTOM FIELDS GROUP } } add_action('admin_init','admin_only_metabox');
Hi roniM,
Please try use Types action hooks "wpcf_admin_post_init", it locate in typesp lugin folder\embedded\includes\fields-post.php, line 110, like this:
add_action('wpcf_admin_post_init', 'admin_only_metabox', 10, 4);
function admin_only_metabox() {
global $current_user;
if($current_user->roles[0] == 'custom_role') {
//HIDE SPECIFIC CUSTOM FIELDS GROUP
...
remove_meta_box($id, $page, $context);
...
}
Regards
Luo
The forum ‘Types Community Support’ is closed to new topics and replies.