0

I developed a plugin for my citrus payment gateway.I created a shortcode to manage it. It was running absolutely fine some days ago.Now I don't know who changed what, now that shortcode is running twice :(

This is my code I am using.

add_shortcode('citrusafterpayment', 'citrusafterpayment_function');

function citrusafterpayment_function()
{

    mail('test.gupta@test.com','check-in','asd');
    global $wpdb;
    if(isset($_REQUEST['TxStatus']) && $_REQUEST['TxStatus'] != '')
    {
       if($TxStatus == 'CANCELED')
        {
           $return_msg = '<div class="row-fluid"><div class="span12"> <div class="error">You have canceled your transaction.</div></div></div>';
          return $return_msg;
        }
    }
}  

I am using this shortcode on one of my webpage. Whenever that page is hitting I am getting emails two times.

I googled it but there is no useful result.

Please help me.

  • in the page make sure you close the shortcode eg: [citrusafterpayment][/citrusafterpayment] – Touqeer Shafi May 27 '15 at 4:39
  • @TouqeerShafi yes it is closed fine. :( – raj aryan May 27 '15 at 4:48
0

Try this way, it's not the proper way to figure it out but it will solve your problem.

function citrusafterpayment_function()
{
    static $calls = 0;

    if($calls == 0){ $calls++;
       mail('test.gupta@test.com','check-in','asd');
       global $wpdb;
       if(isset($_REQUEST['TxStatus']) && $_REQUEST['TxStatus'] != '')
       {
           if($_REQUEST['TxStatus'] == 'CANCELED')
           {
           $return_msg = '<div class="row-fluid"><div class="span12"> <div class="error">You have canceled your transaction.</div></div></div>';
          return $return_msg;
           }
       }  
    }


} 

Edited:

You should pass: $_REQUEST['TxStatus'] in the if statement $TxStatus is not defined in the function.

| improve this answer | |
  • NO. It did not solve it. still getting emails two times :( – raj aryan May 27 '15 at 4:54
  • I think you changed code. and yes now email is coming once but now another issue comes up that the message which I was returning not printing on my webpage – raj aryan May 27 '15 at 4:56
  • Are you sure that $_REQUEST['TxStatus'] are you getting ? – Touqeer Shafi May 27 '15 at 4:59
  • 100% sure. Code under function is working fine. I have tested it so many times. – raj aryan May 27 '15 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.