How to autofill the Advanced Custom Fields with the form's data?

Home Forums Quform WordPress How to autofill the Advanced Custom Fields with the form's data?

This topic is: not resolved
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4185
    haritos
    Participant

    Hello!

    I want to autofill the Advanced Custom Fields , that i use in my posts, with the form’s data as i do in the functions.php with the autopost creation.

    Is this possible to do it?

    e.x. Let’s say i have two custom fields, made by “Advanced Custom Fields”, the “First Name” and the “Last Name”. And i have a form with two fields the “First Name” and the “Last Name”. I want to autofill the custom fields after the submission of the form and make the post in draft status.

    #4221
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #4222
    haritos
    Participant

    Hello Ally,

    I’ve added the code below and works fine:

    add_post_meta($post_id, 'link_diagwnismou', $form->getValue('iphorm_1_11'));

    Thank you for all!

    By the way, use gave me a code to insert the submitted image into the post but by inserting the code in the functions.php an error occurs. This is the code you gave me:
    // Insert the post
    $post_id = wp_insert_post($post);

    // Add attachments
    $file = $form->getValue('iphorm_2_4');

    if (isset($file[0])) {
    $file = $file[0];
    $filename = $file['text'];
    $path = $file['fullPath'];

    $wp_filetype = wp_check_filetype($filename, null);

    $attachment = array(
    'post_mime_type' => $wp_filetype['type'],
    'post_title' => sanitize_file_name($filename),
    'post_content' => '',
    'post_status' => 'inherit'
    );

    $attach_id = wp_insert_attachment($attachment, $path, $post_id);

    require_once(ABSPATH . 'wp-admin/includes/image.php');
    $attach_data = wp_generate_attachment_metadata( $attach_id, $path );
    wp_update_attachment_metadata( $attach_id, $attach_data );

    set_post_thumbnail( $post_id, $attach_id );

    And you also told me to make a change in this:
    $value = array(
    'url' => iphorm_get_wp_uploads_url() . '/' . $result['path'] . $filename,
    'text' => $filename
    );

    To this:
    $value = array(
    'url' => iphorm_get_wp_uploads_url() . '/' . $result['path'] . $filename,
    'text' => $filename,
    'fullPath' => $fullPath
    );

    Please can you tell me what might be the problem?

    #4234
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy