Create post from form data and redirect

Home Forums Quform WordPress Create post from form data and redirect

This topic is: resolved
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #26584
    maxim
    Participant

    I moved it here from Codecanyon.

    So i have a form from witch the data will be stored in a post. I managed to do this using the create plugin version.
    The problem now is that i want to redirect to that page after the user submits the data. I have used the quform_confirmation_redirect_url instead of the quform_post_process but it will always redirect to the url adress i have inserted. How can i change that to go to the newly created page.
    Thank you

    #26587
    katw
    Participant

    Hi @maxim, saw your query and thought I could offer a suggestion.

    Are we redirecting to a “Thank you page” for a customer OR a page to do post-processing of form data?

    If THANKs page:

    From what I understand the quform_confirmation_redirect_url hook is used by ALL confirmations.

    If you have multiple confirmations setup and/or multiple forms you will need to add code within this function to check the form id and the confirmation id for the one you want to change before changing the url returned.

    It may be better to use quform_confirmation_redirect_url_X_X hook and replace the X_X with the confirmation ID you want to trap and work on. Much easier as detection work already done.

    Basic structure refer: quform_confirmation_redirect_url doc.

    Within the function you need to return a fully formed URL which is the path to the page you created.

    If post processing page:

    Have you seen the docs:

    1. Passing data from one form to another
    2. Sending form data to another script

    If you have written code as you have suggested. Sharing it may speed up the solution process.

    #26596
    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.

    #26671
    maxim
    Participant

    hello, sorry for the late reply.
    I want to redirect to a post generated by the form they just completed.
    The post is generated but the redirect is going to the homepage and not the generated page.

    This is the code i have in the custom plugin php:
    <?php

    /*
    * Plugin Name: Quform Custom Code
    * Description: Custom code for Quform.
    * Version: 1.0
    */

    // Paste in your custom code below
    add_filter(‘quform_confirmation_redirect_url_1_1’, function ($url, Quform_Confirmation $confirmation, Quform_Form $form) {
    $url = ‘http://dautor.noocstudio.com/test&#8217;;
    $title = $form->getValue(‘quform_1_9’);
    $content = $form->getValue(‘quform_1_3’);

    $files = $form->getValue(‘quform_1_14’);

    if (isset($files[0][‘url’])) {
    echo ‘‘;
    }

    $post = array(
    ‘post_title’ => $title,
    ‘post_content’ => $content,
    ‘post_type’ => ‘post’,
    ‘post_status’ => ‘publish’
    );

    $postId = wp_insert_post($post);
    wp_set_object_terms($postId, ‘Participant-2018’, ‘category’);

    // Add attachment
    $file = $form->getValue(‘quform_1_10’);

    if (isset($file[0])) {
    $file = $file[0];
    $filename = $file[‘name’];
    $path = $file[‘path’];

    $wpFiletype = wp_check_filetype($filename);

    $attachment = array(
    ‘guid’ => $file[‘url’],
    ‘post_mime_type’ => $wpFiletype[‘type’],
    ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, $filename),
    ‘post_content’ => ”,
    ‘post_status’ => ‘inherit’
    );

    $attachId = wp_insert_attachment($attachment, $path, $postId);

    require_once ABSPATH . ‘wp-admin/includes/image.php’;
    $attachData = wp_generate_attachment_metadata($attachId, $path);
    wp_update_attachment_metadata($attachId, $attachData);

    set_post_thumbnail($postId, $attachId);
    }

    return $url;
    }, 10, 3);

    #26745
    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.

    #26746
    maxim
    Participant

    Hello,
    That works but i need something more.
    I want to use a form-post.php file to edit the layout of the final post.
    Also i have to types of image uploads. One goes to the featured image (that works) and the other i want to make it a gallery (now it only takes the first image and it’s loaded only as single image).

    #26797
    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.

    #26800
    maxim
    Participant

    Hello and thank you for your time. I’m aware that this is custom work that is not included the support and i appreciate it very much. This works excellent.
    I will give a 5 star rating on codecanyon.
    Thanks again and i hope that i was not too much of a hustle.

    #26801
    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 9 posts - 1 through 9 (of 9 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