Support

Account

Home Forums Backend Issues (wp-admin) Restrict editor ACF capability

Solving

Restrict editor ACF capability

    • codynew

    • January 31, 2015 at 5:11 am

    Hi

    I have a team of editors for my website, but I want to completely restrict the access to ACF for them.

    Can you help advise please? The editor role works well for my team in terms of managing writers and rather than create a custom role, I want to remove/restrict access to ANY of the backend ACF pages and stop them from adding/editing any fields.

    Note: I do have User Role Editor Premium which I am using to ‘hide’ the menu, but I would much prefer to completely stop them from accessing the page.

    Any advice please?

    Thanks

    • James

    • June 29, 2015 at 8:45 pm

    Hi @codynew

    Thank you for the question.

    You can make use of the acf/settings filter to restrict the number of people who can edit the ACF fields.

    The code will look as follows:

    add_filter('acf/settings/show_admin', 'my_acf_show_admin');
    function my_acf_show_admin($show) {
    	// provide a list of usernames who can edit custom field definitions here
    	$admins = array( 
    		'user_name_1', 'user_name_2'
    	);
    
    	// get the current user
    	$current_user = wp_get_current_user();
    
    	return (in_array($current_user->user_login, $admins));
    }
  • I thought at one time this setting disabled the editing capability of acf field groups but it only seems to hide and show the admin menu node.

    I am still able to go directly to the acf-field-group admin screens at wp-admin/edit.php?post_type=acf-field-group. Is there a way to disable these from being public?

    • James

    • October 4, 2016 at 10:20 am

    Hi @dylanjameswagner

    In this case, you can use the acf/settings/capability hook instead like this:

    function my_acf_settings_capability( $path ) {
    
        return 'administrator';
    
    }
    
    add_filter('acf/settings/capability', 'my_acf_settings_capability');

    This page should give you more idea about it: https://www.advancedcustomfields.com/resources/acfsettings/.

    I hope this helps 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.