Hi!
I am trying to make the profile picture and the listing picture mandatory, however, although I used the snippet below, and there is a notification that does not let to complete the registration without a picture, the profile image field still says “optional”, so how can I change this so it is required?
I want to do the same for listings. how can I change the snippet so it works for listings too?
add_filter(
'hivepress/v1/models/host',
function( $model ) {
if ( isset( $model['fields']['image'] ) ) {
$model['fields']['image']['required'] = true;
}
return $model;
},
1000
);
add_filter(
'hivepress/v1/forms/user_update/errors',
function( $errors, $form ) {
$user = $form->get_model();
if ( $user && ! $user->get_image__id() ) {
$errors[] = 'Por favor agrega una foto de perfil.';
}
return $errors;
},
100,
2
);
ihor
May 7, 2022, 7:52pm
2
Please try this snippet instead of the first of 2 posted above:
add_filter(
'hivepress/v1/forms/user_update',
function( $form ) {
if ( isset( $form['fields']['image'] ) ) {
$form['fields']['image']['statuses'] = ['optional' => null];
}
return $form;
},
1000
);
Thanks, Ihor, it worked for the profile picture, but it did not work for the listing image.
I tried the snippet below. How can I make it work for the listings?
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if ( isset( $form['fields']['image'] ) ) {
$form['fields']['image']['statuses'] = ['optional' => null];
}
return $form;
},
1000
);
add_filter(
'hivepress/v1/forms/listing_update/errors',
function( $errors, $form ) {
$user = $form->get_model();
if ( $user && ! $user->get_image__id() ) {
$errors[] = 'Por favor agrega una imagen para tu servicio.';
}
return $errors;
},
100,
2
);
Please try this PHP snippet instead
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if ( isset( $form['fields']['images'] ) ) {
$form['fields']['images']['statuses'] = ['optional' => null];
}
return $form;
},
1000
);
system
Closed
June 8, 2022, 7:33am
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.