Deleting guests profile users after 1.5 hours
I need to automatically delete the users that are subscribed through a wpforms after 90 minutes of being created.
Users created this way are marked as invitados on the profile.
I found this answer on a previous question:
if(!wp_next_scheduled('my_dailyClearOut')) {
wp_schedule_event(time(), 'daily', 'my_dailyClearOut'); }
function my_clearOldUsers() {
global $wpdb;
$query = $wpdb-prepare(DELETE FROM $wpdb-users WHERE datediff(now(), user_registered) 30);
if ($oldUsers = $wpdb-get_results($query, ARRAY_N)) {
foreach ($oldUsers as $user_id) {
wp_delete_user($user_id[0]);
}
}
}
add_action('my_dailyClearOut', 'my_clearOldUsers');
However, this deletes all types of users including administrator. I only want to delete the type invitados, I also would like this script to run each 30 minutes and delete all invitados that were created 90 minutes ago.
Can anyone help?