All custom fields disappear from vendor submission form

Hi there,
I added a snippet to hide the manual booking checkbox from the form and suddenly now all custom fields disappear when the snippet is activated. Even after removing the new part of the snippet about the checkbox, all other fields are still gone.

add_filter(
	'hivepress/v1/models/vendor/attributes',
	function( $form ) {
		if ( isset($form['fields']['booking_moderated']) ) {

			$form['fields']['booking_moderated']['editable'] = false;
		}
		
		return $form;
	},
	1000
);

Here is the normal form:



Here the one without any custom fields:

I guess added snippet overwrote something in the database?

Here is the snippet I use now, which still removes all other fields.

//Add description
add_filter(
	'hivepress/v1/forms/user_update_profile',
	function( $form ) {
		$form['description'] = 'Además de tus datos personales, académicos y profesionales, te solicitamos documentación que la empresa que te contrate va a necesitar: <li>vida laboral<li>certificado de estar al corriente de pagos <li>pago de autónomos. <br><br> Puedes subirla ahora o en cualquier otro momento que accedas a tu perfil. Esta documentación no es pública para los usuarios, solo la podrá ver la empresa que te contrate y una vez que se cierre el acuerdo de colaboración.';
		return $form;
	},
  1000
);

//Remove Fields
add_filter(
	'hivepress/v1/forms/vendor_update',
	function($form){
		
		// Hide booking window field.
		unset($form['fields']['booking_window']);
		
		// Hide maximum booking duration field.
		unset($form['fields']['booking_max_length']);
		
		// Hide min booking duration field.
		unset($form['fields']['booking_min_length']);
		
		// Hide min booking offset field.
		unset($form['fields']['booking_offset']);
		
		// Hide booking export url field.
		unset($form['fields']['booking_export_url']);
		return $form;
		
	},
	1000
);

add_filter(
	'hivepress/v1/forms/user_update_profile',
	function($form){
		
		// Hide CIF field.
		unset($form['fields']['cif']);

		// Hide Razon Social field.
		unset($form['fields']['razon_social']);		
		
		return $form;
	},
	1000
);

add_filter(
	'hivepress/v1/forms/vendor_update',
	function ($form){
		if(isset($form['fields']['dirrecion'])){
			$form['fields']['dirrecion']['description'] = 'Calle, Número, Detalles adicionales';
		}
		
		if(isset($form['fields']['hourly_rate'])){
			$form['fields']['hourly_rate']['description'] = 'Si tiene varios, elija el más utilizado.';
		}	
		
	},
	1000
);

Seems like removing that part solves the issue, but I would love to keep these modifications.

add_filter(
	'hivepress/v1/forms/vendor_update',
	function ($form){
		if(isset($form['fields']['dirrecion'])){
			$form['fields']['dirrecion']['description'] = 'Calle, Número, Detalles adicionales';
		}
		
		if(isset($form['fields']['hourly_rate'])){
			$form['fields']['hourly_rate']['description'] = 'Si tiene varios, elija el más utilizado.';
		}	
		
	},
	1000
);

Hi,

Yes, this snippet may remove all the fields because the form is not returned, please try adding this line of code at the end of the function:

return $form;

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.