Reputation: 179
I want to use add_action
to hook 2 functions and right now this is what I have:
add_action( 'wp_ajax_nopriv_function_1', array (
$this,
'function_1'
) );
I tried adding the second function like so:
add_action( 'wp_ajax_nopriv_function_1', array (
$this,
'function_1',
'function_2'
) );
But this doesn't allow either of the functions to work. What is the proper way to do it other than declaring a separate add_action
call?
Upvotes: 1
Views: 2253
Reputation: 3793
You may call second function inside first one as @Danijel wrote in comments. e.g. something like this may work:
add_action('wp_ajax_nopriv_test-action', 'first_1');
function first_1() {
$a = 'abc';
//call second funtion here
$c = second_2();
return $a.$c;
}
function second_2() {
$b = 123;
return $b;
}
Upvotes: 1