Title: Adding custom fields to front end form
Last modified: August 21, 2016

---

# Adding custom fields to front end form

 *  Resolved [georgew0304](https://wordpress.org/support/users/georgew0304/)
 * (@georgew0304)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-fields-to-front-end-form/)
 * Hi,
 * I’m attempting to add custom fields to job entries (such as Salary) for users
   of the website. I’ve managed to make it work on the backend wp-admin side, but
   not for the front end.
 * With the backend, I’ve added an array for salary on `class-wp-job-manager-writepanels.
   php`, I tried the same for `class-wp-job-manager-form-submit-job.php`. I’m able
   to get it to add a meta key of `_job_salary` but the only time I can get it to
   give me a meta value is when adding entries from the back end.
 * I’ve noticed someone else has come across this same problem [here](http://wordpress.org/support/topic/adding-custom-fields-4?replies=2),
   but I still couldn’t work it out using that information.
 * I’ve gone through your GitHub and looked through resources available but nothing.
   The only thing that seemed like a possibility is copying files from `/template`
   into my theme directory. If this is what I need to do, what files do I need to
   edit, and where do I need to make these edits.
 * My PHP isn’t the greatest, but I have a fair bit of knowledge on it.
 * Thanks.
 * [http://wordpress.org/plugins/wp-job-manager/](http://wordpress.org/plugins/wp-job-manager/)

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

 *  Thread Starter [georgew0304](https://wordpress.org/support/users/georgew0304/)
 * (@georgew0304)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-fields-to-front-end-form/#post-4211786)
 * Alright, I’ve managed to get it to show up in the database with a meta key and
   meta value. I’m working on getting it to show up on the job listing now.
 *  Thread Starter [georgew0304](https://wordpress.org/support/users/georgew0304/)
 * (@georgew0304)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-fields-to-front-end-form/#post-4211797)
 * Ah, I have fixed it. It’s a case of adding the function to `wp-job-manager-template.
   php`.
 *  [azizgaruba](https://wordpress.org/support/users/azizgaruba/)
 * (@azizgaruba)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-fields-to-front-end-form/#post-4211941)
 * Hey [@georgew0304](https://wordpress.org/support/users/georgew0304/), can you
   let me know how you did this? I’d like to add a custom field to display Application
   Deadline. My theme makes it easy to add the name and value on the backend. Just
   not sure how to do it on the front end.
 * Thanks.
    [http://wordpress.org/plugins/wp-job-manager/](http://wordpress.org/plugins/wp-job-manager/)
 *  Thread Starter [georgew0304](https://wordpress.org/support/users/georgew0304/)
 * (@georgew0304)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-fields-to-front-end-form/#post-4211942)
 * Right, the first field you need to edit is
    `includes/forms/class-wp-job-manager-
   form-submit-job.php`
 * Around line 100 you need to add an array similar to the following (Use the other
   arrays on the file to give you an idea)
 *     ```
       'application_deadline' => array(
       					'label'       => __( 'Application Deadline', 'job_manager' ),
       					'type'        => 'text',
       					'required'    => true,
       					'placeholder' => '',
       					'priority'    => 7
       				),
       ```
   
 * Make sure you have a different priority to the others.
 * Then around line 435 you need to add a line to put the form input into the database.
 * Add something like this:
    `update_post_meta( self::$job_id, '_application_deadline',
   $values['job']['application_deadline'] );`
 * That should handle the adding the entry to the database side of things.
 * Now to add the function to get the element from the database.
 * Open up the file `wp-job-manager-template.php`
 * You can add this function to the bottom of the file:
 *     ```
       /**
        * Display or retrieve the current application deadline with optional content.
        *
        * @access public
        * @param mixed $id (default: null)
        * @return void
        */
       function the_application_deadline( $before = '', $after = '', $echo = true, $post = null ) {
       	$application_deadline = get_the_application_deadline( $post );
   
       	if ( strlen( $application_deadline ) == 0 )
       		return;
   
       	$application_deadline = esc_attr( strip_tags( $application_deadline ) );
   
       	if ( $echo )
       		echo $application_deadline;
       	else
       		return $application_deadline;
       }
   
       /**
        * get_the_application_deadline function.
        *
        * @access public
        * @param int $post (default: 0)
        * @return void
        */
       function get_the_application_deadline( $post = null ) {
       	$post = get_post( $post );
       	if ( $post->post_type !== 'job_listing' )
       		return;
   
       	$application_deadline = $post->_application_deadline;
   
       	if ( strlen( $application_deadline ) == 0 )
       		return;
   
       	if ( strpos( $application_deadline, '' ) === 0 )
       		$application_deadline = substr( $application_deadline, 1 );
   
       	return apply_filters( 'the_application_deadline', $application_deadline, $post );
       }
       ```
   
 * Now you should just be able to add `<?php the_application_deadline(); ?>` to 
   bring up the application deadline.
 * Just an advisory, I’m not a professional developer. You should look over my code,
   as I’ve mainly looked over current code and replicated it with minor changes.
 *  [badland](https://wordpress.org/support/users/badland/)
 * (@badland)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/adding-custom-fields-to-front-end-form/#post-4211978)
 * Hi [@georgew0304](https://wordpress.org/support/users/georgew0304/)
 * I followed your steps above but I’m having trouble getting any inputted date 
   to stick, as though it is not going into the database – is there any step I may
   have missed out?
 * Thanks
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/adding-custom-fields-to-front-end-form/#post-4211979)
 * **[@ritchie](https://wordpress.org/support/users/ritchie/) Badland**: If you 
   require assistance then, as per the [Forum Welcome](http://codex.wordpress.org/Forum_Welcome#Where_To_Post),
   please post your own topic.

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

The topic ‘Adding custom fields to front end form’ is closed to new replies.

 * ![](https://ps.w.org/wp-job-manager/assets/icon-256x256.gif?rev=2975257)
 * [WP Job Manager](https://wordpress.org/plugins/wp-job-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-job-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-job-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-job-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-job-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-job-manager/reviews/)

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)

 * 6 replies
 * 4 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/adding-custom-fields-to-front-end-form/#post-4211979)
 * Status: resolved