Add Fields with Sub-Fields to WP Job Manager

I have been working on a custom add-on for WP Job Manager where I modify, via filters, the content displayed. I’ve used many of the tutorials on www.wpjobmanager.com/documentation, but I’m stuck on one point.

I’m trying to recreate a feature from the Resumes add-on (demo here) where you can add additional education or experience fields. I am trying to recreate that feature in the main WP Job Manager plugin to populate an optional subfield for addresses.

This is a scaled down version of the code I have for now: http://pastebin.com/fAVq9vfu

I have successfully added the fields and subfields to the form (there is a separate template file that renders the form). They also register in the global $_POST variable as shown when I do a var_dump in the Preview template (sample screenshot), but I am messing up somewhere when it comes to storing the values. None of the fields with subfileds are saving in the post meta data table. I’ve tried a few options, most recently by including and having my class extend WP_Job_Manager_Forms Class (https://github.com/mikejolley/WP-Job-Manager/blob/master/includes/class-wp-job-manager-forms.php). I believe I can accomplish what I am trying to do via the included filters, but I’m not sure which one or how to do it.

I believe I might need to call get_posted_fields() somewhere, because I’m not entirely sure it is catching my custom get_posted_{subfield}_field methods.

Does anyone have any tips?

2 Answers
2

I see a few things missing in your snippet/code.

  1. Each field (your location ones) need to include priority:

    'priority' => 19,

  2. You defined ‘type’ as ‘location’ but did not define that field type. The repeated files in resume manager where you based this code on defines template files for education, experience etc. To define your own filter on ‘job_manager_locate_template’. Quick example https://gist.github.com/mikejolley/76d8b538fe489377793b You’ll need a template file for each of your repeated fields. We may make this simpler in the future, but as I explained via support, repeated fields are new 🙂

Leave a Comment