Reputation: 13511
I like to know, if a user is logged in, the following hooks will run two times the ajax_get_info() function, or the wp_ajax_get_info will run only for logged in users, and wp_ajax_nopriv_get_info will run only for users that are not logged in?
add_action('wp_ajax_get_info', array($this, 'ajax_get_info'));
add_action('wp_ajax_nopriv_get_info', array($this, 'ajax_get_info'));
Upvotes: 0
Views: 134
Reputation: 220066
Your code is correct.
wp_ajax_get_info
will run ONLY for logged-in users, while wp_ajax_nopriv_get_info
will run ONLY for non-logged-in users.
So, the way you did it is correct, and will only ever execute once.
Upvotes: 1