Skip to content

Instantly share code, notes, and snippets.

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 champsupertramp/be017dd19009a580a0ff635f745d7e10 to your computer and use it in GitHub Desktop.
Save champsupertramp/be017dd19009a580a0ff635f745d7e10 to your computer and use it in GitHub Desktop.
Ultimate Member Cron - Delete users awaiting email confirmation after 5 days without getting confirmed
/**
* More Ultimate Member tutorials at www.champ.ninja
*/
add_action( 'um_cron_delete_users_cron', 'um_delete_users_awaiting_email' );
function um_delete_users_awaiting_email(){
$args = array(
'fields' => 'ID',
'number' => -1,
'date_query' => array(
array( 'after' => '5 days ago midnight', 'inclusive' => true ),
),
'meta_query' => array(
"relation" => "AND",
array(
"key" => "status",
"value" => "awaiting_email_confirmation",
"compare" => "="
)
)
);
$users = get_users( $args );
foreach( $users as $user ){
um_fetch_user( $user->ID );
UM()->user()->delete();
}
}
if ( ! wp_next_scheduled( 'um_cron_delete_users_cron' ) ) {
wp_schedule_event( time(), 'daily', 'um_cron_delete_users_cron' );
}
@sagarwalzade
Copy link

Hi,

I have used Real-time Notifications extension of ultimate members plugin.

I want to raise a custom notification when admin submit a post from backend. but i am not able to get that output.

Can you please help me how to implement it with the help of this code i found in their documentation : https://docs.ultimatemember.com/article/53-using-notifications-api-to-add-custom-notifications

I will wait for your response, please message me as early as possible.

Thanks.
Sagar W.

@FromEarthToday
Copy link

FromEarthToday commented Jul 21, 2020

Hi @champsupertramp, looks like a very handy bit of code but on trying to add it to my site (using the Snippets plugin) it shows parse errors on lines 15, 16, 17 and 33 (example from line 15 attached) resulting in a fatal error.

Unfortunately I have very little clue when it comes to this and my usual trial and error has come up fruitless. Pointing in the right direction would be appreciated.

All plugins and core code up to date.

Regards

Add_New_Snippet

@champsupertramp
Copy link
Author

Hi @FromEarthToday - please check the above code snippet. I've updated it. I missed a double qoute in the "AND" condition.

Regards,

@FromEarthToday
Copy link

@champsupertrap

Wow, that was fast, must say I wasn't expecting a reply for a few days, very much appreciated. As for the fix, where's the facepalm emoji when you need it; I changed all the quotes multiple times trying to troubleshoot ... and never even noticed line 10 missing one.

Again, many thanks for the extremely fast reply and resolution. Enjoy your evening :)

Regards

@theBAY84
Copy link

Hey! What do I have to add to the code if I would like to delete all users after 1 hour without getting confirmed? Do I have to replace "5 days ago midnight" or what do I have to add to the code? Best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment