1. Home
  2. Developer
  3. Code Snippets
  4. How to add additional permision/consent checkboxes

How to add additional permision/consent checkboxes

Some users may need to implement more advanced consent collection in their application forms to comply with local data regulations.

This is an advanced example of how you can extend the Matador Jobs form to add additional consent checkboxes.

<?php 
/*
Example code for adding custom consent checkboxes to the application form and having the values of these additional fields synced to a custom object with Bulhorn on application sync.
*/
function COMPANY_NAME_matador_application_fields( $fields ){


	$gdpr_recruiting = "<span style='color:#ca4d2d'>*</span> By checking this box, I agree that COMPANY_NAME  may process my personal data and salary details according to the terms of the <a target='_blank' href='#your-privacy-statement'>Privacy Statement</a>, in order to propose my profile and to transfer my personal data to COMPANY_NAME 's customers / potential customers for fixed-term, permanent or temporary jobs.";
	$gdpr_marketing = "By checking this box, I agree that COMPANY_NAME  may process my personal data for the purpose of promoting marketing activities and commercial communication, including interactive communication, market research and statistical studies, by fax, e-mail, sms and mms.";
	$gdpr_training = "By checking this box, I agree that COMPANY_NAME  may process my personal data according to the terms of the <a target='_blank' href='#your-privacy-statement'>Privacy Statement</a>, in order to organize additional training and to transfer my personal data to training organizations.";

	$fields['gdpr_recruiting'] = array(
		'type' => 'checkbox',
		'class' => 'matador-required',
		'attributes' => array( 'required' => true ),
		'options' => array( '1' => $gdpr_recruiting ),
	);

	$fields['gdpr_marketing'] = array(
		'type' => 'checkbox',
		'options' => array('1' => $gdpr_marketing ),
	);

	$fields['gdpr_training'] = array(
		'type' => 'checkbox',
		'options' => array('1' => $gdpr_training ),

	);

	return $fields;
}
add_filter('matador_application_fields', 'COMPANY_NAME_matador_application_fields');

/**
 * create the object to be saved in Bullhorn
 * @param $person
 * @param $application
 *
 * @return mixed
 */
function COMPANY_NAME_add_data_to_candidate_data( $person, $application ){
	$gpdrs = array();

	if ( isset( $application['gdpr_recruiting'] ) ) {
		$gdpr_recruiting = new stdClass();
		$gdpr_recruiting->text3 = 'Web Reponse';
		$gdpr_recruiting->date1 = (int)( microtime( true ) * 1000 );
		$gdpr_recruiting->date2 = (int)( microtime( true ) * 1000 );
		$gdpr_recruiting->textBlock1 = ( empty( $bhid) ) ? esc_html__( 'No Linked Job', 'matador-jobs' ) : implode( ', ', $bhid );
		$gdpr_recruiting->text1 = 'Recruiting';
		$gdpr_recruiting->text2 = 'Legal Obligation';

		$gpdrs[] = $gdpr_recruiting;
	}

	if ( isset( $application['gdpr_marketing'] ) && ( $application['gdpr_marketing'] ) ) {
		$gdpr_marketing = new stdClass();
		$gdpr_marketing->text3 = 'Web Reponse';
		$gdpr_marketing->date1 = (int)( microtime( true ) * 1000 );
		$gdpr_marketing->date2 = (int)( microtime( true ) * 1000 );
		$gdpr_marketing->textBlock1 = ( empty( $bhid ) ) ? esc_html__( 'No Linked Job', 'matador-jobs' ) : implode( ', ', $bhid );
		$gdpr_marketing->text1 = 'Direct Mail';
		$gdpr_marketing->text2 = 'Express Consent';

		$gpdrs[] = $gdpr_marketing;
	}

	if ( isset( $application['gdpr_training'] ) && ( $application['gdpr_training'] ) ) {
		$gdpr_training = new stdClass();
		$gdpr_training->text3 = 'Web Reponse';
		$gdpr_training->date1 = (int)( microtime( true ) * 1000 );
		$gdpr_training->date2 = (int)(microtime( true ) * 1000 );
		$gdpr_training->textBlock1 = ( empty( $bhid ) ) ? esc_html__( 'No Linked Job', 'matador-jobs' ) : implode( ', ', $bhid );
		$gdpr_training->text1 = 'Training';
		$gdpr_training->text2 = 'Express Consent';

		$gpdrs[] = $gdpr_training;
	}

	if ( ! empty($gpdrs)) {
		//NOTE:; you need to check that your consent is "customObject1s" in Bullhorn
		$person->customObject1s = $gpdrs;
	}
	
	return $person;
}

add_filter( 'matador_submit_candidate_candidate_data', 'COMPANY_NAME_add_data_to_candidate_data', 10, 2 );


/**
 * Processes application data based on GDPR compliance provided in the request.
 *
 * @param array $application The application data array to be processed and updated.
 * @param array $request The request data containing GDPR-related information.
 *
 * @return array The updated application data array with GDPR compliance information.
 */
function matador_application_data_processed( $application, $request ){
	if ( isset( $request['gdpr_recruiting'] ) ) {
		$application['application']['gdpr_recruiting'] = true;
	}

	if ( isset( $request['gdpr_marketing'] ) && ( count( $request['gdpr_marketing'] ) > 1 ) ) {
		$application['application']['gdpr_marketing'] = true;
	} else {
		$application['application']['gdpr_marketing'] = false;
	}

	if ( isset( $request['gdpr_training'] ) && ( count( $request['gdpr_training'] ) > 1 ) ) {
		$application['application']['gdpr_training'] = true;
	} else {
		$application['application']['gdpr_training'] = false;
	}

	return $application;
}

add_filter( 'matador_application_data_processed' , 'matador_application_data_processed', 10, 2 );


/**
 * Adds additional fields to the application related to GDPR compliance.
 *
 * @param array $fields The array of existing fields to which new fields will be added.
 *
 * @return array The updated array of fields including GDPR-related fields.
 */
function matador_fields_to_add_to_application( $fields ){
	$fields[] = 'gdpr_recruiting';
	$fields[] = 'gdpr_marketing';
	$fields[] = 'gdpr_training';

	return $fields;

}

add_filter( 'matador-fields-to-add-to-application' , 'matador_fields_to_add_to_application' );

Updated on August 27, 2025
Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support