I have build a function to fetch a post in Wordpress served over ajax.
$.ajax({
url: '/wp-admin/admin-ajax.php',
type: 'POST',
cache: false,
data: {
action: 'get_post_info',
postId: postId,
},
success: function(data){
});
In order to make it work if the user is not logged in, I have used wp_ajax_nopriv. But when the user is logged in now, the functionality crashes.
add_action('wp_ajax_nopriv_get_post_info', 'get_post_info');
function get_post_info(){
}
Is there a function like wp_ajax that work for both logged_in and not logged_in users?
ajaxurl
is defined, see note here.