Quantcast
Channel: Topic Tag: forms | WordPress.org
Viewing all articles
Browse latest Browse all 3048

FeedQ on "[Plugin: Jetpack by WordPress.com] Jetpack Contact Form"

$
0
0

I'd like to use Jetpack Contact Form for some blog contests. The basic layout of the form is the same for every form, but the question type and the question differ between forms.

Always the same

  • Always 3 questions
  • Always one address field
  • Always one email field
  • Always the same receiver

Different between forms

  • Answer can be 1 of 3 radio buttons or a single text field answer
  • Questions are different between forms

Since we have quite a few contests per week. I would like to create the fields "on the fly" based on set custom fields in the post. Tried doing something like this:

<?php
	// Get question and type Q1
	if (get_post_meta($post->ID, '_cmeta_contest_q1_type', true) !== 'field') {
		$cq1 = "type='radio' options='". get_post_meta($post->ID, '_cmeta_contest_q1_radio', true) ."'";
	} else {
		$cq1 = "type='text'";
	}

	$question1 = get_post_meta($post->ID, '_cmeta_contest_q1', true);

	// Get question and type Q2
	if (get_post_meta($post->ID, '_cmeta_contest_q2_type', true) !== 'field') {
		$cq2 = "type='radio' options='". get_post_meta($post->ID, '_cmeta_contest_q2_radio', true) ."'";
	} else {
		$cq2 = "type='text'";
	}

	$question2 = get_post_meta($post->ID, '_cmeta_contest_q2', true);

	// Get question and type Q3
	if (get_post_meta($post->ID, '_cmeta_contest_q3_type', true) !== 'field') {
		$cq3 = "type='radio' options='". get_post_meta($post->ID, '_cmeta_contest_q3_radio', true) ."'";
	} else {
		$cq3 = "type='text'";
	}

	$question3 = get_post_meta($post->ID, '_cmeta_contest_q3', true);

	// Get contest form title
	$contest_title = the_title_attribute( 'echo=0' );

    echo do_shortcode("
      [contact-form to='s@ve.me' subject='". $contest_title ."']
      [contact-field label='". $question1 ."' ". $cq1 ." required='1'/]
      [contact-field label='". $question2 ."' ". $cq2 ." required='1'/]
      [contact-field label='". $question3 ."' ". $cq3 ." required='1'/]
      [contact-field label='Namn och adress' type='textarea' required='1'/]
      [contact-field label='E-postadress' type='email' required='1'/]
      [/contact-form]
    ")
?>

The output from this is correct, but I'm guessing something isn't loading in the right order or something like that because the form won't submit, it just reloads.

What am I missing, is it possible to do it like this at all?

http://wordpress.org/extend/plugins/jetpack/


Viewing all articles
Browse latest Browse all 3048

Trending Articles