Support » Developing with WordPress » Passing over data from one function to another

  • Hi there, I’m building a plugin. The plugin has a core file which generates everything, but also has the functions that do some api calls.

    Whenever a user fills in an email and clicks on submit, a jquery ajax call will be done to one of my php functions. In there I make an external api call and retrieve a customer object.

    Next step is somehow passing over the customer id and some other values to another api call which will be performed when you submit another form. The easiest way seems to use hidden inputs in my current form, but I don’t want users to be able to manipulate the data.

    Here’s my function where I retrieve a customer and some other details:

    add_action('wp_ajax_nopriv_search_customer', 'search_customer');
    	add_action('wp_ajax_search_customer', 'search_customer');
    	//method for cancel membership form
    	function search_customer(){
    		$email = $_GET['customerEmail'];
    		$val = new Validation();
    		$val->name('customerEmail')->nl_name('Klant email')->value($email)->pattern('email')->required();
    		$result = [];
    			$validateEmail = (new SportivityClient(13653))->validateCustomerEmail(['email' => $email, 'mem' => 'T']);
    			if($validateEmail['error']['HttpStatusCode'] == 200){
    				$client = new SportivityClient(13653);
    				$object = [];
    				$object['customer'] = $client->getCustomerByEmail(['email' => $email, 'mem' => 'T']);
    				$object['subscriptions'] = $client->getSubscriptions();
    				$object['reasons'] = $client->getReasons();
    			} else {
    				$result['errors']['customerEmail']['nl_msg'] = 'Email niet gevonden.';
    		} else {
    			$result['errors'] = $val->getErrors();
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.