ID, 'vsai_known_ips', true ); if ( ! is_array( $known ) ) { $known = array(); } if ( in_array( $ip, $known, true ) ) { return; } $first = empty( $known ); $known[] = $ip; update_user_meta( $user->ID, 'vsai_known_ips', array_slice( array_unique( $known ), -5 ) ); if ( $first ) { return; // Primera vez: solo se aprende la IP, no se asusta a nadie. } vsai_alerts_send( 'admin_new_ip_' . $user->ID, __( 'Notice: an administrator signed in from a new place', 'vidal-security-ai' ), array( sprintf( /* translators: 1: usuario 2: IP */ __( 'The administrator account “%1$s” just signed in from an IP never seen on that account before: %2$s.', 'vidal-security-ai' ), $user_login, $ip ), __( 'If it was you (travel, another network, another device), ignore this notice. If you do not recognise the sign-in, change that account’s password right now.', 'vidal-security-ai' ), ) ); }, 10, 2 ); /* 3. Cuenta administradora nueva ----------------------------------------- */ add_action( 'user_register', function ( $user_id ) { if ( ! vsai_alerts_enabled() ) { return; } $user = get_userdata( $user_id ); if ( ! $user || ! in_array( 'administrator', (array) $user->roles, true ) ) { return; } vsai_alerts_send( 'new_admin', __( 'Alert: a new administrator account was created', 'vidal-security-ai' ), array( sprintf( /* translators: 1: usuario 2: correo */ __( 'An account with administrator powers was just created: “%1$s” (%2$s).', 'vidal-security-ai' ), $user->user_login, $user->user_email ), __( 'If it was not you, go to Users right now and delete it: it is the classic way of planting a backdoor in a site.', 'vidal-security-ai' ), ), 10 * MINUTE_IN_SECONDS ); } );