skip to Main Content

I wanted to use wordpress ‘tera wallet’ plugin’s functions in standalone cron file which is configured under cpanel -> Cron Jobs

php -q /home3/samadha1/xxxx.in/wp-content/plugins/woo-wallet/cfile.php

2

Answers


  1. WordPress has the own cron system.

    For using cron by command line need to change wp-config.php :

    1. Open your wp-config.php file

    2. Go to the bottom of the database settings in wp-config.php. Add the code:

    define('DISABLE_WP_CRON', 'true');
    

    For scheduling your task need to use the function "wp_schedule_event"

    register_activation_hook( __FILE__, 'wpshout_plugin_activation' );
    
    function wpshout_plugin_activation() {
        if ( ! wp_next_scheduled( 'wpshout_do_thing' ) ) {
            wp_schedule_event( time(), 'daily', 'wpshout_do_thing' );
        }
    }
    

    After this, you can add the cron command to "Cron Jobs":

    php -q /home3/samadha1/xxxx.in/wp-cron.php
    
    Login or Signup to reply.
  2. You could just include wp-load.php from your your cfile.php.

    <?php
    require_once __DIR__ . '/../../../wp-load.php';
    
    // check if woo-wallet has been enabled 
    if (!is_plugin_active('woo-wallet/woo-wallet.php')) {
      echo 'woo-wallet plugin is not active';
      exit(1);
    }
    
    // call any function of woo-wallet
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search