ControlledChaos of Controlled Chaos Design
8/9/2016 - 6:44 PM

Hide the Advanced Custom Fields UI in admin menu, free version 4

Hide the Advanced Custom Fields UI in admin menu, free version 4

<?php

function remove_acf_menu() {
    // provide a list of usernames who can edit custom field definitions here
    $admins = array( 
        'admin', 
        'johndoe'
    );

    // get the current user
    $current_user = wp_get_current_user();

    // match and remove if needed
    if( !in_array( $current_user->user_login, $admins ) )
    {
        remove_menu_page('edit.php?post_type=acf');
    }
}

( 'admin_menu', 'remove_acf_menu', 999 );

?>

Hide the Advanced Custom Fields UI in admin menu, free version 4

WordPress Snippet