Skip to content

Instantly share code, notes, and snippets.

@Dinamiko
Created October 10, 2015 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dinamiko/57847c00a75ff2fc8f26 to your computer and use it in GitHub Desktop.
Save Dinamiko/57847c00a75ff2fc8f26 to your computer and use it in GitHub Desktop.
<?php
/**
* crea registro con datos desde el formulario
*/
function encuesta_ajax() {
// verifica nonce
if ( ! isset( $_POST['encuesta_nonce_field'] ) || ! wp_verify_nonce( $_POST['encuesta_nonce_field'], 'encuesta_action' ) ) {
print 'Sorry, your nonce did not verify.';
exit;
} else {
$result['type'] = 'success';
$result['msg'] = 'testeando...';
$result = json_encode( $result );
echo $result;
wp_die();
}
}
add_action('wp_ajax_encuesta_ajax', 'encuesta_ajax' );
add_action('wp_ajax_nopriv_encuesta_ajax', 'encuesta_ajax' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment