Support

Account

Home Forums Front-end Issues Post-id doesn’t work as it should using a GET

Helping

Post-id doesn’t work as it should using a GET

  • Hello, I have a problem that is giving me a headache. I used the acf_form() function to create a custom form on the front end, using a variable post-id through a GET. I thought everything had worked out, if it weren’t for the fact that the form is taking that id, and saving it somewhere else, I don’t know which, but it certainly isn’t updating the custom post with the id determined in the GET. (The strange thing is that when I change the id in the GET it changes the form, but I have no idea which post it is taking and changing as they are not the ones I wanted.)

    Everything seems to work normally, with the execution of editing and saving the correct item

    Here is the code used:

    <?php
    $postid = $_GET['postid'];
    acf_form(array(
    'post_id' => $postid,
    'fields' => array('target','target_year'),
    'submit_value' => __("Save")
    ));?>

    Thank you for your help

  • I honestly don’t see why it’s not working.

    Try changing this
    $postid = $_GET['postid'];
    to
    $postid = intval($_GET['postid']);

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

You must be logged in to reply to this topic.