I'm adding custom user meta in wordpress admin, and I would like my two custom fields are required, but how I show error and tell wordpress to not update profile if error ?
add_action('personal_options_update', 'sweety_admin_update_extra_profile_fields');
add_action('edit_user_profile_update', 'sweety_admin_update_extra_profile_fields');
function sweety_admin_update_extra_profile_fields($user)
{
$error = false;
if (is_super_admin())
{
if (!$_POST['country'] || !$_POST['timezone'])
{
$error = true;
}
update_user_meta($user, 'country_id', $_POST['country']);
update_user_meta($user, 'timezone_string', $_POST['timezone']);
}
}