Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm attempting to set up a fairly long multi-part form (~50 questions, a few questions per page) with conditional logic. I'd like to offer registered visitors the ability to save their data between each page/step and give them the option to return later to finish.

I have Gravity Forms and thought that might work, but it sounds like this isn't functionality they offer yet.

Does anyone have any advice/suggestions on other form plugins or code which might meet these requirements? Thanks in advance for all your help!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you are working on a custom theme, I believe it is easier to be done with a page template and WordPress's wp_ajax function.

The form can be included in the page using <?php get_template_part('form','0f-50-question') ?>.

Here is the pseudo code for the form

<form id="quite-a-long-form" action="<?php echo admin_url('admin-ajax.php'); ?>" method="post" class="form" >
    $step = $_GET['step']
    if $step = 1
        //first section of question
        echo <label>
        echo <input>
        echo <label>
        echo <input>
    else if $step = 2
        //second section of question
        echo <label>
        echo <input>
        echo <label>
        echo <input>
    else if $step = 3
        //third section of question
        echo <label>
        echo <input>
        echo <label>
        echo <input>
    // just repeat for all sections
    endif
    <input type="Submit">
    <?php wp_nonce_field('input-answer','security-code-here'); ?>
    <input name="action" value="input-answer" type="hidden">
</form>

And for the php that will process the file

function process_add_transfer() {
    if ( empty($_POST) || !wp_verify_nonce('security-code-here','add_transfer') ) {
        echo 'You targeted the right function, but sorry, your nonce did not verify.';
        die();
    } else {
        // do your function here 
        wp_redirect($_POST['_wp_http_referer'].'?step='.$index_of_the_next step);
    }
}

Hope this help

share|improve this answer
    
Thanks, I will try that! –  Michelle Aug 5 '12 at 23:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.