• Hello,

    I can’t manage to set my Types checkboxes using add_post_meta on a custom form sending. I tried serialising my variable before using the function, it is successfully created in the DB but nothing checked in my post edit screen. Am I getting this wrong ?

    Here is the related code :

    $fiche = array(
    'post_title' => $_POST['nom'],
    'post_content' => "",
    'post_type' => 'fiche-animal',
    'post_status' => 'draft'
    );
    $id_post = wp_insert_post($fiche);
    add_post_meta( $id_post, 'wpcf-urgence', $_POST['urgence'] );

    “urgence” being my checkboxes array.

    Thank you in advance.
    Latverius

    https://www.ads-software.com/plugins/types/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter latverius

    (@latverius)

    Sorry, the code is wrong, here it is :

    $urgence = serialize($_POST['urgence']);
    $fiche = array(
    'post_title' => $_POST['nom'],
    'post_content' => "",
    'post_type' => 'fiche-animal',
    'post_status' => 'draft'
    );
    $id_post = wp_insert_post($fiche);
    add_post_meta( $id_post, 'wpcf-urgence', $urgence );

    Thread Starter latverius

    (@latverius)

    Has nobody any idea on how to make it work ? :/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Setting Types checkboxes using add_post_meta’ is closed to new replies.