Cron removes after sometime in wordpress plugin (Advance cron manager)

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I am using Advance Cron Manager in wordpress for cron, but my cron removes after some time 24-48 hours, I am unable to detect what causing this. I have checked the code and paseted below from my custom plugin. I am using whatsapp chat-api to detect if there is new message received/sent to whatsapp, I am using emails to sent whatsapp message once new email is sent with certain headers, it will hit below function and sent message to whatsapp.

To check this I have scheduled a cron new_email_event after every 1 minute, sometimes it workes ok but some time it removes after 10 minutes.

I want to know is this an issue with plugin or I am missing something.

https://bracketspace.com/downloads/advanced-cron-manager-pro/

This is code written in my custom plugin.

add_action('new_email_event', 'identify_new_email_received');

function identify_new_email_received() {    
    ini_set('display_errors', '1'); 
    $settings = odz_get_whatsappsmtp_settings();    
    include(dirname(__FILE__).'/src/PhpImap/__autoload.php');   

    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
    $username = $settings['configured_email'];
    $password = $settings['email_password'];

    $mailbox = new PhpImap\Mailbox('{imap.gmail.com:993/imap/ssl}INBOX', $username, $password);
    //$mailbox = new PhpImap\Mailbox('{imap.gmail.com:993/imap/ssl}INBOX', $settings['configured_email'], $settings['email_password'], __DIR__);                

    $since_date = date('Y-m-d',strtotime("-1 days"));       
    $mailsIds = $mailbox->searchMailbox('SINCE "'.$since_date.'"'); 

    if(!$mailsIds) {
        my_custom_log('No emails');     
    }


    $email_data = array();
    if(!get_site_option('wp_last_email_time')){
        my_custom_log('No last email');
        //whatsapp the last email
        $latest_mail = count($mailsIds) -1;
        $mail = $mailbox->getMail($mailsIds[$latest_mail]);
        $email_data['date'] = $mail->date;
        $email_data['text'] = $mail->textPlain;
        $email_data['id'] = $mail->id;
        $email_data['subject'] = $mail->subject;
        $email_data['fromAddress'] = $mail->fromAddress;
        $email_data['fromName'] = $mail->fromName;
        $sender = get_sender_number($mail->textHtml);
        $msg = get_sender_message($mail->textHtml);
        if(!empty($msg)){
            $email_data['text'] = $msg;
        }

        if(!empty($sender)){
            $mailbox->deleteMail($mail->id);
                                                
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.