Is possible to pass params from controller (plugin) to ajax action?

Question

I need change status in marketplace and they have a code:

// Update Vendor Approval Response
    add_action( 'wp_ajax_wcfmvm_vendor_approval_response_update', array( &$this, 'wcfmvm_vendor_approval_response_update' ) );

This function is run from Ajax

var data = {
    action     : 'wcfmvm_vendor_approval_response_update',
    wcfm_vendor_approval_response_form : jQuery('#wcfm_vendor_approval_response_form').serialize()
}   
jQuery.post(wcfm_params.ajax_url, data, function(response) {

Function for this action is

function wcfmvm_vendor_approval_response_update() {
    global $WCFM, $WCFMvm, $_POST, $wpdb;

    $wcfm_vendor_approval_response_form_data = array();
    parse_str($_POST['wcfm_vendor_approval_response_form'], $wcfm_vendor_approval_response_form_data);

In my plugin i would like do action with params but with no results. This is what i am trying to do:

global $_POST;

 $abc = [
     'wcfm_vendor_approval_response_status' => 'approve',
     'wcfm_vendor_approval_member_id' => 71,
     'wcfm_vendor_approval_message_id' => 82,
 ];

$_POST['wcfm_vendor_approval_response_form'] = http_build_query($abc);

do_action('wp_ajax_wcfmvm_vendor_approval_response_update');

How can i do action with pass params ?

0
Wraith 2 years 2019-12-29T06:30:44-05:00 0 Answers 104 views 0

Leave an answer

Browse
Browse