bvdr
4/7/2015 - 10:49 AM

Include Advanced Custom Fields - ACF in theme and hide the "CUSTOM FIELDS" menu item from other users except yours ( in this case "developer

Include Advanced Custom Fields - ACF in theme and hide the "CUSTOM FIELDS" menu item from other users except yours ( in this case "developer" ). Please make sure you change the paths to your project needs. Also consider to have the /fields/ folder created and with the proper permissions.

//region ADD ACFP
/**
 * ACF INCLUDE
 **/

include_once( 'inc/acfp/acf.php' );

add_filter( 'acf/settings/path', 'cf_settings_path' );
function cf_settings_path( $path ) {
	$path = get_stylesheet_directory() . '/inc/acfp/';

	return $path;
}

add_filter( 'acf/settings/dir', 'cf_settings_dir' );
function cf_settings_dir( $dir ) {
	$dir = get_stylesheet_directory_uri() . '/inc/acfp/';

	return $dir;
}

add_filter( 'acf/settings/save_json', 'cf_json_save_point' );
function cf_json_save_point( $path ) {
	$path = get_stylesheet_directory() . '/inc/fields/';

	return $path;
}

add_filter( 'acf/settings/load_json', 'cf_json_load_point' );
function cf_json_load_point( $paths ) {
	$paths[] = get_stylesheet_directory() . '/inc/fields/';

	return $paths;
}

wp_get_current_user();

if ( $user_login != 'developer' ) {
	add_filter( 'acf/settings/show_admin', '__return_false' );
}
//endregion