• Hi

    I’m trying write a wp plugin and want to post a form using HTTP POST. The problem is I can’t receive $_POST when submit my form in plugin’s class. It works outside my class only.

    I hooked the function using this in my class constructor:
    add_action('admin_post_add_foo', array($this, 'add_foo')

    And in a function let’s say I just want to dump $_POST var:

    public function add_foo() {<br />
       var_dump($_POST);<br />
    }

    which doesn’t work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • In the form target URL, use this:
    https://yoursite.com/

    Instead of https://yoursite.com

    $_POST not works in wordpress endponts. you must receive posted data and store it in a global variable directly in plugin file then you can access that global variable every where. also you can use admin-ajax.php which is provided by wordpress for receiving posted data in wordpress.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can't receive $_POST or $_GET var in WP Plugin’ is closed to new replies.