Fix for internal cron while using Groups

Hello itthinx-Team,

I was nagged by a blocked cron routine updating articles. In particular it was Event Organizers ICS-calenders imported from Outlook.com. They started to appear as doubles as the catergory they got assigned to was blocked by Restrict Category. The developer from Event Organizers helped and the following was his feedback… please consider it:

It’s my opinion that the restrictions shouldn’t apply during a cron routine, since the purpose of such routines is to perform tasks on the website – and ones which you wouldn’t generally allow a logged-out user to do (e.g. membership plug-ins will use these to charge accounts, update membership, and WordPress core uses these to delete and publish posts). As such I don’t think it’s appropriate to apply restrictions during such processes.

I would encourage you to open a forum thread with the plug-in developer. I would have done so myself, but it is restricted only to customers. I’m more than happy to discuss this with them, so feel free to point them to my contact form: http://wp-event-organiser.com/contact, if they wish to do so.

That said, below is a ‘fix’. You will need to create a plug-in for this. You could try it in your theme’s functions.php but you will need to uncomment the first line. It hasn’t been tested inside a theme, but has been tested in a plug-in.

The snippet below effectively prevents the plug-in from doing anything during a cron job:


//add_action( 'after_setup_theme', 'grc_cron_fix' );
add_action( 'plugins_loaded', 'grc_cron_fix' );
function grc_cron_fix(){
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
remove_action( 'init', array( 'Groups_Restrict_Categories', 'wp_init' ), apply_filters( 'groups_restrict_categories_init_priority', 999 ) );
}
}

All the best,
Stephen


Comments

3 responses to “Fix for internal cron while using Groups”

  1. Thanks for the hint as well Dieter, it will be forwarded too.

  2. Little further hint… the fix has to be placed in a mu-plugin to prioritize the regular plugins … read the hint from Stephen:

    In that case you might want put it in a plugin – or simpler yet, an mu-plugin (see for example: http://gregrickaby.com/create-mu-plugin-for-wordpress/), and put the code in there.

    Stephen

  3. Hi Dieter,

    Thanks a lot for all the detailed and descriptive information you provided, we appreciate the feedback.
    I hope that the suggested snippet allows your configuration to work normally and i will forward this topic to our development team for further investigation.

    Kind regards,
    George

Share