WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a plugin which has a front end form that is generated by a shortcode. I'm struggling with processing the form submission in any way. Many tutorials describe placing form processing code at the top of a template file. But as a plugin I don't have a template file.

This is what I have at the moment. The shortcode just calls this function:

function get_testimonial_submission_form () {
<form action="" id="testimonialPostForm" method="POST">

        <label for="testimonialclientname"><?php _e('Name:', 'rhl-testimonial') ?></label>
        <input type="text" name="testimonialclientname" id="testimonialclientname" />

        <input type="hidden" name="submitted" id="submitted" value="true" />
        <button type="submit"><?php _e('Submit Feedback', 'rhl-testimonial') ?></button>


<span class="error">Result is <?php echo $testResult; ?></span>
<div class="clearfix"></div>


And for form processing, I'm using this test code:

function testimonial_submission_form(){
    if($_POST['testimonialclientname'] == ''){
        $testResult = 'Yes';
     } else {
        $testResult = 'No';

add_action( 'init', 'testimonial_submission_form' );

Currently after submitting the form, $testResult is empty.

share|improve this question
In both of your functions, $testResult is a local variable, see variable scope in php docs. – Milo May 16 '13 at 15:46
Ah cr... Yeah that was all I needed! If you want, paste that as an answer for the points. – Cormac May 16 '13 at 18:22

Your Answer


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

Browse other questions tagged or ask your own question.