Hi there Team HP
We’re trying to make the Vendor profile description required.
We have modified and constructed the following code snippet from Make the profile description field required #hivepress #users · GitHub and changed the form name to user_update_profile as we want it to affect the Vendor profile form.
add_filter(
'hivepress/v1/forms/user_update_profile',
function( $form ) {
if(isset($form['fields']['description'])){
$form['fields']['description']['label'] = 'Profile Description';
$form['fields']['description']['required'] = true;
}
return $form;
},
1000
);
But its not working for the Vendor profile form user_update_profile , as the description field remains optional.
If we use the original snippet with from name user_update , the snippet works fine but on the User profile form and we’d like it to work only on the Vendor profile form.
andrii
August 7, 2023, 1:47pm
4
Hi,
If you need it for vendors only, please try this hook hivepress/v1/forms/vendor_update
Filter: hivepress/v1/forms/{form_name} | HivePress Hook Reference
I hope this is helpful to you.
Hi Andrii
Nope, still not making the description in the Vendor profile a required filed.
add_filter(
'hivepress/v1/forms/vendor_update',
function( $form ) {
if(isset($form['fields']['categories'])){
$form['fields']['categories']['multiple'] = true;
$form['fields']['categories']['description'] = '(select the category type/s that best describe what you will be listing)';
}
if(isset($form['fields']['description'])){
$form['fields']['description']['label'] = 'Profile Description';
$form['fields']['description']['required'] = true;
}
return $form;
},
1000
);
We’re also using a snippet with hook hivepress/v1/forms/user_update to set the description field to false so its not required for Buyer type accounts.
Is the one maybe overriding the other?
yevhen
August 9, 2023, 9:05pm
7
Please try this PHP code snippet
add_filter(
'hivepress/v1/models/vendor',
function($model){
$model['fields']['description']['required'] = true;
return $model;
},
1000
);
add_filter(
'hivepress/v1/forms/user_update',
function($form_args, $form){
$user = $form->get_model();
if(!$user){
return $form_args;
}
$vendor = \HivePress\Models\Vendor::query()->filter(['user' => $user->get_id()])->get_first_id();
if(!$vendor){
return $form_args;
}
$form_args['fields']['description']['required'] = true;
return $form_args;
},
1000,
2
);
add_filter(
'hivepress/v1/forms/user_update_profile',
function($form_args, $form){
$form_args['fields']['description']['required'] = true;
return $form_args;
},
1000,
2
);
Hi there Team HP (Andrii & Yevhen)
@Yevehn - That script isn’t targeting the Vendor profile form either.
If you maybe want to have a look see what the issue might be and possibly tweak the script on the site itself, Ihor and Andrii have a temp login link due to custom development Team HP has done for us.
The script should be the last snippet added with the WPCode Snippets plugin (unless we add more before you get to it), but its titled Vendor Profile Form (user_update) - Profile Description Set Rquired .
THANKS!
andrii
August 11, 2023, 9:04am
10
Hi,
We updated the PHP snippets you added, and everything seems to work. The issue is that you didn’t add all the snippets that Yevhen posted above.
I hope this is helpful to you.
system
Closed
September 10, 2023, 9:05am
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.