My JSON file
{ "objects": [
{
"secuencial_persona": 00001,
"identificacion": "xxxxxxxx",
"nombre_persona": "xxxxxxxxxxxxxxxxxx",
"perfil": "USUARIO",
"estado": "ACTIVO",
"email": "xxxxxxxxxx@outlook.com"
},
{
"secuencial_persona": 11126,
"identificacion": "dddddddddddd",
"nombre_persona": "ddddddddddddddddddddddd",
"perfil": "USUARIO",
"estado": "ACTIVO",
"email": "dddddddddd@hotmail.es"
},
{
Plugin WordPress
if (!is_admin()) {
//activate only when post email
if (isset($_POST['email']) || isset($_POST['user_email'])) {
add_filter('is_email', array($this, 'isEmail'), 11, 2);
add_filter('registration_errors', array($this, 'CTH_email_validator_wprg'), 1, 3);
add_filter('user_profile_update_errors', array($this, 'availableError'));
add_filter('login_errors', array($this, 'availableError'));
}
}
I’m base on a plugin that makes a e mail validation to an exterior api. When registering or writing the e-mail, a perform that makes a request to an API with the e-mail and confirm that it exists, if it exists it allows you to register but when it doesn’t exist you can’t register.
public perform CTH_email_check($e mail)
{
if (is_admin()) {
// If consumer have logged as admin, which means likely they're modifying the settings, let it go if is_email been known as.
return true;
}
if (($_SERVER['REQUEST_URI'] == '/wp-login.php') | ($_SERVER['REQUEST_URI'] == '/wp-login.php?loggedout=true') | ($_SERVER['REQUEST_URI'] == '/wp-cron.php')) {
// if wp-login.php is been known as for login to dashboard, skip the verify.
return true;
}
// Test the formatting is appropriate
if (filter_var($e mail, FILTER_VALIDATE_EMAIL) === false) {
return false;
}
$flag = false;
//For testing i used a json file
$response = plugin_dir_url(__FILE__) . "belongings/usuarios.json";
//$response = wp_remote_get("http://url" . $e mail);
$response_data = json_decode($response);
$physique = @json_decode($response_data);
$email_data = $body->objects;
// Traverse array and show consumer knowledge
foreach ($email_data as $consumer) {
if ($user->e mail == $e mail) {
$flag = true;
break;
}
}
}
Sadly I do not know if I am heading in the right direction and it might assist me so much for those who can information me.