I wrote this simple function to prefill a field if a user value is present, otherwise I want it to fallback to another value. The first part works, prefilling the user value, however the fallback (if there is no user value) does not.
I’m no developer so I’ve probably just missed something basic, any nudge in the right direction would be appreciated!
add_filter('acf/load_field/name=system_galaxy', 'set_galaxy_default');
function set_galaxy_default($field) {
$uid = get_current_user_id();
$user_pref = get_user_meta( $uid, 'user_current_galaxy' );
if ($user_pref != '') {
$value = $user_pref;
} else {
$value = 1130;
}
if (!$field['value']) $field['value'] = $value;
return $field;
}