Retrieving $_POST Variables in wordpress page (1 post)

  1. sahilsaid
    Posted 2 years ago #

    I am trying to create a wordpress plugin for a payment gateway. The gateway sends a data back on given URL (in my case : mysite.com/payment-success). On this URL I have a set wordpress to email as soon as it detects posted variables as well as update database result of that particular payment.

    Can someone please tell me how I can retrieve all POST variables sent from external URL in wordpress.

    This is what I am doing at the moment.

    add_shortcode('payment_success_wp', array($this, 'payment_success')); //second argument is array because function is in a class file.
    function payment_success() {
        global $wpdb;
        $this->table_name = $wpdb->prefix . "my_payments";
        mail('myemailaddress@gmail.com', "about payments", "just chasing up" . print_r($_POST));
        if (isset($_POST['transactionstatus']) && isset($_POST['total'])) {
            $data = array(
                'payment_status' => $_POST['transactionstatus'],
            $wpdb->update($this->table_name, $data, array('payment_id' => $_POST['oid']));

    I have added above shortcode on new page with the URL mysite.com/payment-success. The function (shortcode) implementation is as below. .

    When I call above page manually then the email does get trigger. Which I think is really strange but when the gateway sends parameters to payment-success page then nothing happens.

Topic Closed

This topic has been closed to new replies.

About this Topic