Pages

Jun 20, 2016

Create CRON In wordpress with custom interval


Create CRON In wordpress with custom interval


// add custom interval
function cron_add_minute( $schedules ) {
// Adds once every minute to the existing schedules.
    $schedules['everyminute'] = array(
   'interval' => 60,
   'display' => __( 'Once Every Minute' )
    );
    return $schedules;
}
add_filter( 'cron_schedules', 'cron_add_minute' );



add_action('recheck_event', 'recheck_verification');

function schedule_event() {
if ( !wp_next_scheduled( 'recheck_event' ) ) {
wp_schedule_event( current_time( 'timestamp' ), 'everyminute', 'recheck_event');
}
}
add_action('wp', 'schedule_event');

function recheck_verification() {

 //You Custom Function

}

Jun 18, 2016

Prevent admin notification email for new registered users or user password changes

This is a simple method to prevent any mails to admin which normaly takes place on new user registration or user changes there password. Put this function on your Function.php file any where.

// prevent admin notification email for new registered users or user password changes



function conditional_mail_stop() {

    global $phpmailer;

    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    $subject = array(
        sprintf(__('[%s] New User Registration'), $blogname),
        sprintf(__('[%s] Password Lost/Changed'), $blogname)
    );

    if ( in_array( $phpmailer->Subject, $subject ) )
        // empty $phpmailer class -> email cannot be send
        $phpmailer = new PHPMailer( true );

}

add_action( 'phpmailer_init', 'conditional_mail_stop' );