Make the attachment mandatory

Hi,
I want to make the attachment mandatory when candidates send an application (message) to the company.

This will help filtering applications.

Any help?

Please try this PHP snippet

add_filter(
	'hivepress/v1/models/message/errors',
	function ( $errors, $message ) {
		if(get_option( 'hp_message_allow_attachment' ) && !$message->get_attachment()){
			$errors[] = 'Attachment is required field';
		}
		
		return $errors;
	},
	1000,
	2
);

add_filter(
	'hivepress/v1/forms/message_send',
	function ( $form ) {
		if(get_option( 'hp_message_allow_attachment' )){
			$form['fields']['attachment']['required'] = true;
		}
		
		
		return $form;
	},
	1000
);

perfect! thank you!

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