Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mike Jolley

    (@mikejolley)

    What code did you try?

    Thread Starter binyaminmellish

    (@binyaminmellish)

    // Add a new field
    add_filter( 'job_application_form_fields', 'custom_job_application_form_fields' );
    
    function custom_job_application_form_fields( $fields ) {
      $fields[ 'your_field' ] = array(
        		'label'       => 'Where Did You Hear About This Job',
    			'type'        => 'select',
    			'1'	  	  => '1',
    			'required'    => true,
    			'options'     => array( '0' => __( 'N/A', 'wp-job-manager-applications' ) ),
    			'priority'    => 3
      );
      return $fields;
    }
    
    // Add new field data to meta array so its saved and stored
    add_filter( 'job_application_form_posted_meta', 'custom_job_application_form_posted_meta' );
    
    function custom_job_application_form_posted_meta( $meta ) {
      $meta['your_field'] = sanitize_text_field( $_POST['your_field'] );
      return $meta;
    }
    
    // Add a line to the notifcation email with custom field
    add_filter( 'create_job_application_notification_message', 'custom_create_job_application_notification_message', 10, 2 );
    
    function custom_create_job_application_notification_message( $message, $application_id ) {
      $message[] = "\n" . "Your field was set as: " . get_post_meta( $application_id, 'your_field', true );
      return $message;
    }
    Plugin Author Mike Jolley

    (@mikejolley)

    That appears to work; just needs extra options:

    'options'     => array( '0' => 'N/A', 'test' => 'test', 'test2 => 'test2' ),
    Thread Starter binyaminmellish

    (@binyaminmellish)

    It did work. Thank you.

    // Add a new field
    add_filter( 'job_application_form_fields', 'add_application_form_source_field' );
    
    function add_application_form_source_field( $fields ) {
      $fields[ 'source' ] = array(
        		'label'       => 'Where Did You Hear About This Job',
    			'type'        => 'select',
    			'required'    => true,
    			'options'     => array( 'Twitter' => 'Twitter', 'Referall' => 'Referall', 'Indeed' => 'Indeed' ),
    			'priority'    => 3
      );
      return $fields;
    }
    
    // Add new field data to meta array so its saved and stored
    add_filter( 'job_application_form_posted_meta', 'custom_job_application_form_posted_meta' );
    
    function custom_job_application_form_posted_meta( $meta ) {
      $meta['source'] = sanitize_text_field( $_POST['source'] );
      return $meta;
    }
    
    // Add a line to the notifcation email with custom field
    add_filter( 'create_job_application_notification_message', 'application_form_source_field_posted_meta', 10, 2 );
    
    function application_form_source_field_posted_meta( $message, $application_id ) {
      $message[] = "\n" . "Source: " . get_post_meta( $application_id, 'source', true );
      return $message;
    }
    Thread Starter binyaminmellish

    (@binyaminmellish)

    Thanks.

    Glad we could help! 🙂 Feel free to leave a kind review too.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Application – Create drop down’ is closed to new replies.