Skip to content

Instantly share code, notes, and snippets.

@jprieton
Created March 31, 2015 20:20
Show Gist options
  • Save jprieton/743b48446942382116b8 to your computer and use it in GitHub Desktop.
Save jprieton/743b48446942382116b8 to your computer and use it in GitHub Desktop.
EnvialoSimple Member Edit
<?php
add_action('wp_ajax_envialosimple_member_edit', function() {
// Get the results
$baseURL = 'https://app.envialosimple.com';
$apiKey = '';
$remote_url = $baseURL . '/member/edit/format/json';
$params = array();
$params['APIKey'] = $apiKey;
$params['MemberID'] = filter_input($INPUT_POST, 'suscriber_id');
$params['MailListID'] = 3;
$params['Email'] = filter_input(INPUT_POST, 'suscriber_email');
$params['CustomField1'] = filter_input(INPUT_POST, 'suscriber_first_name');
$params['CustomField2'] = filter_input(INPUT_POST, 'suscriber_last_name');
$response = wp_remote_post($remote_url, array(
'body' => $params
));
$ajaxResponse = json_decode($response['body'])->root->ajaxResponse;
if (!empty($ajaxResponse->success) && $ajaxResponse->success == 1) {
wp_send_json_success(array(
'code' => 'subscribe_success',
'message' => 'Suscripción exitosa'
));
} else {
wp_send_json_error(array(
'code' => 'subscribe_error',
'message' => 'Error en la suscripción',
'error' => $ajaxResponse->errors
));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment