Skip Navigation

[Resolved] Hide Custom Fields Group for specific user role only

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 11 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

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.

Author
Posts
#56946

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');
#56956

Luo Yang
This answer solved user's issue.

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.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.