如何在wordpress中的function.php中获取会话值

时间:2015-10-27 11:33:49

标签: php wordpress session

这里我附上了我的function.php代码

add_action('paypal_ipn_for_wordpress_payment_status_completed','process_payment', 10, 1);
function process_payment( $posted )
{    
$email12= $_SESSION['email12'];
$id1=$_SESSION['id'];
$date=$_SESSION['date'];
// Parse data from IPN $posted[] array
$first_name = isset($posted['first_name']) ? $posted['first_name'] : '';
$last_name = isset($posted['last_name']) ? $posted['last_name'] : '';
$payment_amount = isset($posted['mc_gross']) ? $posted['mc_gross'] : '';
$recurring_payment_id = isset($posted['recurring_payment_id']) ? $posted['recurring_payment_id'] : '';
$payer_email = isset($posted['payer_email']) ? $posted['payer_email'] : '';
$txn_id = isset($posted['txn_id']) ? $posted['txn_id'] : '';
$receiver_email= isset($posted['receiver_email']) ? $posted['receiver_email'] : '';   
    $mail_From    = $payer_email;
    $mail_To      = $receiver_email;
$mail_Subject = "VERIFIED IPN";
    $mail_Body    = "Hello Secretary,
                 New registration for the event: 
                     Name: $first_name $last_name";
 mail($mail_To, $mail_Subject, $mail_Body, $mail_From);   
$mail_From    = $receiver_email;
    $mail_To      = $payer_email;
    $mail_Subject = "VERIFIED IPN";
    $mail_Body    = "Thank you for registration. Your registration has been successfully done.";
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);                                                              require_once('wp-config.php');
 global $wpdb;                  
$id12 = $wpdb->get_results("SELECT * FROM wp_nonmembersdetail where Email= '$email12'  ");
foreach($id12 as $row1)
 {
$wpdb->insert( wp_checkoutnonmembersdetails, array( 
                            'Event_Name' => $row1->Event_Name,
            'First_Name' => $row1->First_Name,
            'Last_Name' => $row1->Last_Name, 
            'Address' => $row1->Address, 
            'Email' => $row1->Email, 
            'cellphone' => $row1->cellphone, 
            'quantity' => $row1->quantity,
                            'payment_amount' => $payment_amount
    ) );
 }  
$id22 = $wpdb->get_results("SELECT * FROM wp_tmpmembersdetail where  id = '$id1' ");
foreach($id22 as $row2)
{
$wpdb->insert( wp_checkouttmpmembersdetail, array( 
                            'Event_Name' => $row2->Event_Name,
            'First_Name' => $row2->First_Name,
            'Last_Name' => $row2->Last_Name, 
            'Address' => $row2->Address, 
            'Email' => $row2->Email, 
            'cellphone' => $row2->cellphone, 
            'quantity' => $row2->quantity,
                            'payment_amount' => $payment_amount
    ) );
    }}

我发现function.php中没有问题我认为IPN挂钩存在问题。 bcz我已经在我的另一个钩子代码中得到了会话值,这个钩子代码也在function.php中,并且工作也很完美。上面我附上了IPN钩子代码。我希望获得email12的会话值。请有人帮助我。

0 个答案:

没有答案