How to run SQL query from WordPress ‘WP Crontrol’ plugin

I managed to get things working by using: include_once(“wp-config.php”); include_once(“wp-includes/wp-db.php”); global $wpdb; $sql = “UPDATE wp_pmpro_memberships_users SET wp_pmpro_memberships_users.status=”admin_cancelled” WHERE wp_pmpro_memberships_users.user_id IN ( /*Select all users that have an active Membership but no active Subscription*/ SELECT pmpro.user_id FROM wp_pmpro_memberships_users as pmpro JOIN wp_pmpro_membership_levels as pmprol ON pmprol.id=pmpro.membership_id JOIN wp_users ON pmpro.user_id = wp_users.ID WHERE pmpro.status=”active” AND … Read more

Cron job to change CPT

Try something like this: if (!wp_next_scheduled(‘update_members_types’)) { wp_schedule_event( time(), ‘daily’, ‘update_members_types’ ); } add_action ( ‘update_members_types’, ‘update_member_post_type’ ); function update_member_post_type() { $args = array( ‘post_type’ => ‘member’, ‘posts_per_page’ => ‘1’, ‘date_query’ => array( array( ‘after’ => strtotime( ‘-24 hours’ ) ) ) ); $members = get_posts( $args ); if ( $members ) { foreach ( … Read more

Activate Plugin Automatically After Set Time

Add this to the functions.php file of your active (child) theme- add_action( ‘init’, ‘wpse_393267_activate_plugin’ ); function wpse_393267_activate_plugin() { if( !function_exists( ‘is_plugin_active’ ) ) { include_once ABSPATH . ‘/wp-admin/includes/plugin.php’; } $plugin_to_activate=”jetpack/jetpack.php”; // plugin-dir/plugin-file.php $date_to_activate=”2021-08-13″; // YYYY-MM-DD if( is_plugin_active( $plugin_to_activate ) ) return; if( time() >= strtotime( $date_to_activate ) ) { activate_plugin( $plugin_to_activate ); } } Change … Read more

Cron: Update four post at Hour

This code will call your function every hour. // The ‘if’ condition is needed to make sure the scheduler runs only once if ( ! wp_next_scheduled( ‘my_custom_action’ ) ){ wp_schedule_event( time(), ‘hourly’, ‘my_custom_action’ ); } // Here we create our own action to attach to the scheduler add_action( ‘my_custom_action’, ‘update_content’ ); It is also recommended … Read more