Hi there !
Is it possible to hide first name, last name, description fields for “normal” users, but make them required if the user wants to submit a listing (when he needs to complete his/her profile).
Here’s my code (based on this one)
add_filter(
'hivepress/v1/forms/user_update',
function( $form ) {
if(current_user_can('edit_posts')){
$form['fields']['first_name']['required'] = true;
$form['fields']['last_name']['required'] = true;
$form['fields']['image']['statuses']['optional'] = null;
}else{//remove for normal users (client)
unset($form['fields']['first_name']);
unset($form['fields']['last_name']);
unset($$form['fields']['image']);
unset($form['fields']['description']);
}
return $form;
},
1000
);
What it does at the moment : hide (remove) the fields in any case (normal profile / complete your profile).
Any idea ?