• Resolved pilot911

    (@pilot911)


    WpeMatico version: 1.0

    I have set up WpeMatico per the instructions and set up about 30 campaigns.

    If i run a campaign from the all campaign’s list or from inside a campaign itself everything works fine. However when i try to schedule using the internal cron or the host cron nothing happens.

    Just to be sure here is the set up:

    In the campaign i set following:

    Activate Scheduling to Yes
    Create a schedule every 20 mins, past the hour

    Check feed all ok and save the campaign.

    In the all campaigns screen the next run Next Run time is at 10.20 pm so that is fine in the future as expected.

    At 10.20pm the cron activates but nothing is posted. (there are posts in the feed).

    I notice that the data for Last Run and Next Run has not changed.

    I also tried setting a server level cron job (tick box in settings) to disable Wp-Cron.

    Use Cron job of Hoster and disable WP_Cron
    You must set up a cron job that calls:
    php -q /home/public_html/wp-cron.php

    This does not seem to work either.

    Any ideas.

    http://wordpress.org/extend/plugins/wpematico/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey There,

    I am also running into this issue and think I may have uncovered the problem.

    In the functions.php file is the function

    function wpematico_cron() {
    		$args = array( 'post_type' => 'wpematico', 'orderby' => 'ID', 'order' => 'ASC' );
    		$campaigns = get_posts( $args );
    		foreach( $campaigns as $post ) {
    			$campaign = WPeMatico :: get_campaign( $post->ID );
    			$activated = $campaign['activated'];
    			$cronnextrun = $campaign['cronnextrun'];
    			if ( !$activated )
    				continue;
    			if ( $cronnextrun <= current_time('timestamp') ) {
    				WPeMatico :: wpematico_dojob( $post->ID );
    			}
    		}
    	}

    If you are at all familiar with the function with get_posts for wordpress you would instantly notice what might cause an issue. the parameter of the function numberposts is not set. By default wordpress get_posts will only get 5 posts. So in this case 5 campaigns will run. If you are fortunate to only have 5 campaigns that need to run you would be fine. If you have more though, like your 30, it will not get to all of them. The case I am working on has 570 campaigns in it.

    The Fix:
    add the argument 'numberposts' => -1 to that function. However be careful, editing a plugin file can have undesired results, and if you upgrade the plugin it will be overwritten.

    function wpematico_cron() {
    		$args = array( 'post_type' => 'wpematico', 'orderby' => 'ID', 'order' => 'ASC' , 'numberposts' => -1 );
    		$campaigns = get_posts( $args );
    		foreach( $campaigns as $post ) {
    			$campaign = WPeMatico :: get_campaign( $post->ID );
    			$activated = $campaign['activated'];
    			$cronnextrun = $campaign['cronnextrun'];
    			if ( !$activated )
    				continue;
    			if ( $cronnextrun <= current_time('timestamp') ) {
    				WPeMatico :: wpematico_dojob( $post->ID );
    			}
    		}
    	}

    A safer route maybe to create a simliar function and access the WPeMatico class to use it’s functions, but for a quick fix that should do it.

    Sorry that functions.php file I refer to is located in wp-content/plugins/wpematico/app/

    Thread Starter pilot911

    (@pilot911)

    Hi natereist,

    Thanks I am going to take a look tomorrow now.

    Appreciate the help.

    Thread Starter pilot911

    (@pilot911)

    Hi natereist,

    It works perfectly. Thanks.

    I also posted a link back to this on the plugin designers website.

    Thanks

    Plugin Author etruel

    (@etruel)

    thanks to all. I’ll include this at next release.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WPeMatico] Cannot get cron to automatically create posts’ is closed to new replies.