Home › Forums › Backend Issues (wp-admin) › Remove ACF from Wp-admin Menu
Hey,
I am trying to remove the ACF page from the wp-admin menu using remove_menu_page('edit.php?post_type=acf');
in my functions.php file.
This used to work fine up until updating to 3.7.1 and ACF 4.3. I am using the remove_menu_page for other pages and they are not being displayed. Any ideas?
Hi @wleefro
Something strange has happened in WP 3.7.1 in regards to menu functions.
I’ll take a look.
Thanks
E
Hi wleefro & Elliot,
I stumbled upon this problem myself today whilst preparing a website for delivery to a client.
The thing that appears to have changed in WP is the order in which the “add_action” for triggering the function with the “remove_menu_page” to remove the ACF menu item is executed.
This used to be after the “add_menu_page” that is used within the ACF plugin, but now it runs before the menu item is added so it is not removed in the end.
So what I’ve simply done to make it work is change the order (priority) for my removal function to ‘999’ so it is executed after ACF adds the item to the menu:
function remove_acf_menu() {
remove_menu_page('edit.php?post_type=acf');
}
add_action( 'admin_menu', 'remove_acf_menu', 999);
It might be a good idea to update the following “How to” page with this information since I also ended up on that page whilst searching:
http://www.advancedcustomfields.com/resources/how-to/how-to-hide-acf-menu-from-clients/
docs were never updated so many thanks to Ernst for posting a working method.
However I add this to the functions.php and now no one, including me as admin, can see the Custom Fields menu 🙁
function remove_acf_menu(){
global $current_user;
if ($current_user->user_login!='admin'){
remove_menu_page( 'edit.php?post_type=acf' );
}
}
add_action( 'admin_menu', 'remove_acf_menu', 100 );
The URL of the ACF page has changed to this:
edit.php?post_type=acf-field-group
So updating the function will make it work again:
function remove_acf_menu(){
global $current_user;
if ($current_user->user_login!='admin'){
remove_menu_page( 'edit.php?post_type=acf-field-group' );
}
}
add_action( 'admin_menu', 'remove_acf_menu', 100 );
And just a general tip – please do no use “Admin” as the admin username of your wordpress site. It’s a security thing…
I recognize that this is an old thread, but wanted to add something that I constructed using this info that I found handy. I used ACF to add a true/false field to user forms. I called it “show_custom_fields_admin”. Then I use the above code in conjunction with the value of that true/false field to hide or display the ACF menu.
function remove_acf_menu(){
global $current_user;
$show = get_field('show_custom_fields_admin',$current_user);
if (!$show){
remove_menu_page( 'edit.php?post_type=acf-field-group' );
}
}
add_action( 'admin_menu', 'remove_acf_menu', 100 );
When adding the true/false field to the user form, be sure to show it only if the user’s role is “admin”.
The topic ‘Remove ACF from Wp-admin Menu’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.