I have writed a lugin that will send emails after the user completed a custom registration form. I need to send emails after 24 hours from registration, is this possible by using the wp mail function?
UPDATE
Not sure if this can work as expected but I've added as suggested a custom action hooc into the construct of my plugin class in this way
add_action('send_login_credential', array($this, 'send_scheduled_registration_email'));
And into the function that will manage the ause registration approval, I've added the code for the cron in this way
$user_email = $customer->user_email;
$num_t = sanitize_text_field( $request->get_param('numTessera') );
$subject = 'User approved';
$message = ".... \n";
$message .= "...: $num_t \n";
$message .= "...password: \n";
$message .= "$password \n";
//
wp_schedule_single_event( DAY_IN_SECONDS * 1, 'send_login_credential', array( $user_email, $subject, $message ));
the function that will be called from the custom action hook will only contain the logic to send the email
public function send_scheduled_registration_email( $user_email, $subject, $message )
{
//add_action('send_login_credential', array($this, 'send_scheduled_registration_email'));
$message_sent = wp_mail( $user_email, $subject, $message );
if( $message_sent ){
return [
'status' => 'ok'
];
}
}
Is there something I will need to do in the code or it can work?