Support

Account

Home Forums Front-end Issues ACF and WP Job Manager Front End

Solving

ACF and WP Job Manager Front End

  • Hi,
    I’m trying to integrate an ACF field group inside an existing WPJM Front End; I can call the Fields without any problem inside the front end, but problems arise when I try to save the fields content to the post.
    When I try to create a post via front-end it saves the fields’ input in post_option (without any wpjm field), and when I try to update an existing job it saves the acf fields content inside the post_meta of the post id in wich the wpjm shortcode is called and not in the existing job post.
    I’m integrating the forms with acf_form() the group array and form=>false, and I’ve inserted acf_form_head() before get_header inside my template.
    Do you know how i can solve these problems?

  • You need to include the argument

    
    'form' => false,
    

    when calling acf_form and put the form inside of the existing form used by the other plugin. https://www.advancedcustomfields.com/resources/acf_form/

  • I’ve already included the form=>false argument.

    This is the code I’m using

    acf_form(array(
    'field_groups' => array(12116),
    'form' => false	));

    but it isn’t working

  • I thing the problem may be the post ID.

    When creating a new post you’ll need to set up the “new_post” information that’s needed for creating a new post in the correct custom post type. When it’s an existing post you need to get the current post_id for the post being edited.

  • WP Job Manager has a 3 step function to create post: the first step is the form submission and when you hit the preview button the post is saved as a draft (wpjm “preview” post) and you are redirected to a preview of the post, which is the second step; from the second step you can submit the post publishing the draft or go back to the editing part. The third step is a redirect to a confirmation page.
    I’ve already tried declaring the post id as new_post in the form array, but it’s not working as I need.

    The front end editing is a single step process that updates the post_meta, but when I try to insert the acf form it uses the front end page id instead of the job id.

    I modified the preview step inserting the acf form and it saves everything fine (I think because it call the job post inside the preview so acf knows what is the postid) but stop the php function that create the submission confirmation page.
    Also if i try to edit the job in the front end because it is a one step process the preview isn’t shown so I can’t edit the acf form.

  • You may have gone beyond my ability to help you. ACF form does not really have the ability to do multi-step form submissions, that I know of. There have been some topics here about them, but I don’t know if those people ever found a solution.

    In the new post process it sounds like you won’t know what the new post ID will eventually be until the first part of the form is submitted in WPJM. You may be able to work around this by creating you own pre_save_post filter https://www.advancedcustomfields.com/resources/acf-pre_save_post/ but even here, I’m not sure how you’d do this if WPJM does not assign the post ID until after the first part of the form is submitted. The pre_save_post filter fires before anything is saved, however, WPJM must be using a similar mechanism and the order could be completely dependent on the order that the plugins are loaded, depending on how they do it. When a post on the front end is submitted, ACF looks at $_POST[‘acf’] to see if it contains anything. If it does then it saves the values. This is done at the top of your template output before WP starts outputting the filter. If WPJM has saved the draft post before this happens then you should be able to get the post ID that was saved in a pre_save_post filter and return that post ID for ACF to use.

    For the editing process, you will need to figure out how to get the actual post ID of the WPJM post that is actually being edited instead of the current page ID. Of the two I think that this might be the easier to accomplish. But like I said, I don’t know anything about WPJM.

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

The topic ‘ACF and WP Job Manager Front End’ is closed to new replies.