I'm working on an ajax request, I have several ajax requests on my functions.php. And all are working, but this:
On my php I have this:
add_action("wp_ajax_fb_points", "get_fb_points");
add_action("wp_ajax_nopriv_fb_points", "get_fb_points");
function get_fb_points(){
if ( !wp_verify_nonce($_REQUEST['nonce'], 'fb_points_nonce')) {
exit('No naughty business');
}
echo 'yeah';
die();
}
On the footer.php I have this:
FB.Event.subscribe('edge.create',
function(response) {
if(response == '<?php echo get_facebook_profile('link'); ?>') {
$.ajax({
url: '<?php echo admin_url('admin-ajax.php'); ?>',
data: { action: 'fb_points', challenge : 2, nonce : '<?php echo wp_create_nonce('fb_points_nonce'); ?>' },
async: false,
success: function(data){
console.log(data);
}
});
}
}
);
But I don't know why it isn't working the request response is "No naugty business". Can anyone help me to find out what is wrong?
$_REQUEST['nonce']andwp_create_nonce('fb_points_nonce')values? – Rilwis Sep 6 '12 at 5:54get_current_user_id(). I don't know why but I changed withwp_get_current_user()and it solves de problem. – jepser Sep 6 '12 at 6:34