• Hey everyone, I’m building a simple plugin that displays a form, and then posts the data back to itself for processing. But it seems that nothing ever gets posted, the post variables are always empty. When I just put the code inside a template, though, it works fine.

    Is there something that disables my $_POST variables if I run it through a filter? Maybe I am missing something.

    Thanks, here’s some code if it helps:

    function spurl($content) {
    global $wp_query;
    $post_ID = $wp_query->post->ID;

    if($post_ID == 121) {
    $id = $_GET['id'];

    if(!isset($id)) {

    $content = '';
    $content .= '<form id="demoform" action="' . get_bloginfo ( 'url' ) . '?page_id=' . $post_ID . '" method="post">';

    $content .= '<input type="text" name="first" value="fist" />';

    $content .= '<p><input type="submit" name="submit" value="SUBMIT" /></p>';

    $content .= '</form>';

    if (isset($_POST['submit'])) {

    header('Location: http://www.google.com/');

    }

    }

    }

    return $content;

    }

    add_filter ( 'the_content', 'spurl' );

Viewing 1 replies (of 1 total)
  • Thread Starter justinbriggs1

    (@justinbriggs1)

    I found the error, it was the attempt to define the current page with bloginfo; I just left the form action blank, which I was under the impression would not work with WP, but now everything is in working order.

Viewing 1 replies (of 1 total)

The topic ‘$_post variables inside a plugin’ is closed to new replies.