Home › Forums › General Issues › Insert custom fields inside a WP job manager submit listing
I am trying to include custom fields inside a WP Job Manager submit listing within the Listify theme so I can send/edit the fields through the listing form but even though I have read this post here:
I can’t seem to be able to do it. Can anyone help?
Could you please share the code you use to add the ACF form to the WP Job Manager form? Could you please tell me what’s not working with that code? Did it show any error message? Did the entries saved in the database?
Thanks 🙂
Hi, thanks for getting back!
The template in question is called job-submit.php
<?php
/**
* Job Submission Form
*/
if ( ! defined( 'ABSPATH' ) ) exit;
global $job_manager;
?>
<form action="<?php echo esc_url( $action ); ?>" method="post" id="submit-job-form" class="job-manager-form" enctype="multipart/form-data">
<?php do_action( 'submit_job_form_start' ); ?>
<?php if ( apply_filters( 'submit_job_form_show_signin', true ) ) : ?>
<?php get_job_manager_template( 'account-signin.php' ); ?>
<?php endif; ?>
<?php if ( job_manager_user_can_post_job() || job_manager_user_can_edit_job( $job_id ) ) : ?>
<!-- Job Information Fields -->
<?php do_action( 'submit_job_form_job_fields_start' ); ?>
<?php foreach ( $job_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php esc_attr_e( $key ); ?>">
<label for="<?php esc_attr_e( $key ); ?>"><?php echo $field['label'] . apply_filters( 'submit_job_form_required_label', $field['required'] ? '' : ' <small>' . __( '(optional)', 'wp-job-manager' ) . '</small>', $field ); ?></label>
<div class="field <?php echo $field['required'] ? 'required-field' : ''; ?>">
<?php get_job_manager_template( 'form-fields/' . $field['type'] . '-field.php', array( 'key' => $key, 'field' => $field ) ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_job_form_job_fields_end' ); ?>
<!-- Company Information Fields -->
<?php if ( $company_fields ) : ?>
<h2><?php _e( 'Company Details', 'wp-job-manager' ); ?></h2>
<?php do_action( 'submit_job_form_company_fields_start' ); ?>
<?php foreach ( $company_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php esc_attr_e( $key ); ?>">
<label for="<?php esc_attr_e( $key ); ?>"><?php echo $field['label'] . apply_filters( 'submit_job_form_required_label', $field['required'] ? '' : ' <small>' . __( '(optional)', 'wp-job-manager' ) . '</small>', $field ); ?></label>
<div class="field <?php echo $field['required'] ? 'required-field' : ''; ?>">
<?php get_job_manager_template( 'form-fields/' . $field['type'] . '-field.php', array( 'key' => $key, 'field' => $field ) ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_job_form_company_fields_end' ); ?>
<?php endif; ?>
<?php do_action( 'submit_job_form_end' ); ?>
<p>
<input type="hidden" name="job_manager_form" value="<?php echo $form; ?>" />
<input type="hidden" name="job_id" value="<?php echo esc_attr( $job_id ); ?>" />
<input type="hidden" name="step" value="<?php echo esc_attr( $step ); ?>" />
<input type="submit" name="submit_job" class="button" value="<?php esc_attr_e( $submit_button_text ); ?>" />
</p>
<?php else : ?>
<?php do_action( 'submit_job_form_disabled' ); ?>
<?php endif; ?>
</form>
In my functions.php on my child theme, I have
add_filter( 'submit_job_form_fields', 'frontend_add_custom_fields' );
function frontend_add_custom_fields( $custom_fields ) {
$custom_fields = acf_form(array(
'field_groups' => array(856),
'form' => false ));
return $custom_fields;
}
where 856 seems to be the Group ID.
I can now see the fields at the top of the page but there are some errors and some fields wp job manager fields are missing:
Warning: include(SITEROOT/wp-content/themes/listify/inc/integrations/wp-job-manager/templates/form-fields/-field.php): failed to open stream: No such file or directory in SITEROOT\wp-content\plugins\wp-job-manager\wp-job-manager-template.php on line 26
Warning: include(): Failed opening 'SITEROOT/wp-content/themes/listify/inc/integrations/wp-job-manager/templates/form-fields/-field.php' for inclusion (include_path='.;DRIVEROOT\xampp\php\PEAR') in SITEROOT\wp-content\plugins\wp-job-manager\wp-job-manager-template.php on line 26
Also the fields are not saved when hitting Preview
In the edit job listing page I can also see the ACF custom fields but some wp job listing fields still missing and the ACF custom fields are not saved when I click Update.
By using the 'form' => false
option, you need to create a custom code to handle the saving process. To do that, you need to know how WP Job Manager form works and add the update_field() function to save the posted custom field to the database. I believe you can get the custom fields data from the form like this:
$custom_field_data = $_POST['acf']['field_1234567890abc']
Where ‘field_1234567890abc’ is the key of your custom field.
Regarding the warning messages, I’m afraid I’m not able to give you direction regarding that issue. Could you please ask it to WP Job Manager support?
I hope this makes sense. Thanks 🙂
Custom Field For WP Job Manager plugin allow you to add custom field text and select box
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.