Support

Account

Home Forums ACF PRO Certain fields not working when imported with PHP Reply To: Certain fields not working when imported with PHP

  • I’ve looked into this more and the problem is nothing to do with the names.

    It’s if I attach functions to the options.

    For example, I have an option called “hide_tools” and then a function like so:

    	if(get_field('hide_tools', 'options')) {
    		
    		function remove_admin_menu_items() {
    			if(!current_user_can('activate_plugins')) {
    				$remove_menu_items = array(('Tools'));
    				global $menu;
    				end ($menu);
    				while (prev($menu)){
    					$item = explode(' ',$menu[key($menu)][0]);
    					if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
    					unset($menu[key($menu)]);}
    				}
    			}
    		}
    		add_action('admin_menu', 'remove_admin_menu_items');
    	
    	}
    

    As long as that function exists in my plugin, the “Hide Tools” checkbox doesn’t appear.

    This must mean ACF is choking on that function, but this only happens when it is imported using PHP.

    What can I do?