سؤال

I have added custom payment method to woocommerce and its working fine . I just have one problem that it calls a callback url for saving transaction information to db. I have created new function for this in my plugin file but i cant excess it directly . This is how i have done it:

//add_action('wp_ajax_nopriv_payment_callback_action', 'payment_callback_action');

//function function payment_callback_action() { echo "Its Working!"; }

I am trying to access it by : url:"<?=site_url( '/' );?>wp-admin/admin-ajax.php?action=payment_callback_action

It seemd that it because of i dnt have privillage to use it directly but how can i do this ?. Thanks

هل كانت مفيدة؟

المحلول

# for users not logged in
add_action('wp_ajax_nopriv_payment_callback_action', 'dixipay_callback_action');

# for users logged in
add_action('wp_ajax_payment_callback_action', 'dixipay_callback_action');

# Your callback
function dixipay_callback_action() { 
  echo "Its Working!"; 
}

read more: http://codex.wordpress.org/AJAX_in_Plugins

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top