<?php
/*
Plugin Name: [yourname] Cron Jobs
Version: 1.0
Description: Cron Jobs for [yoursite]
Author: [yourname]
*/
//handle registration/deregistration
register_activation_hook(__FILE__, 'yourname_activate');
register_deactivation_hook(__FILE__, 'yourname_deactivate');
//add actions
add_action('yourname_daily_event', 'yourname_daily');
function yourname_activate() {
if (!wp_next_scheduled('yourname_daily_event')) {
wp_schedule_event(time(), 'daily', 'yourname_daily_event');
}
}
function yourname_deactivate() {
wp_clear_scheduled_hook('yourname_daily_event');
}
function yourname_daily() {
foreach (get_users_of_blog () as $user)
{
$user = new WP_User ($user->ID);
/**/
if (strtotime ($user->user_registered) <= strtotime ("-30 days"))
$user->add_cap ("access_s2member_ccap_30days");
/**/
if (strtotime ($user->user_registered) <= strtotime ("-60 days"))
$user->add_cap ("access_s2member_ccap_60days");
/**/
if (strtotime ($user->user_registered) <= strtotime ("-90 days"))
$user->add_cap ("access_s2member_ccap_90days");
}
}
?>
Statistics: Posted by smitchell360 — January 11th, 2011, 5:31 pm
Statistics: Posted by plrblockbusters — January 4th, 2011, 4:28 pm
<?php
function my_s2_cron_job ()
{
if ($_GET["my_s2_cron_job"])
{
foreach (get_users_of_blog () as $user)
{
$user = new WP_User ($user->ID);
/**/
if (strtotime ($user->user_registered) <= strtotime ("-30 days"))
$user->add_cap ("access_s2member_ccap_30days");
/**/
if (strtotime ($user->user_registered) <= strtotime ("-60 days"))
$user->add_cap ("access_s2member_ccap_60days");
/**/
if (strtotime ($user->user_registered) <= strtotime ("-90 days"))
$user->add_cap ("access_s2member_ccap_90days");
}
exit ();
}
}
add_action ("init", "my_s2_cron_job");
?>
Statistics: Posted by plrblockbusters — December 7th, 2010, 7:35 pm
Title: An Example Post C
- require Custom Capability: 90days
Title: An Example Post A
- require Custom Capability: 30days
Statistics: Posted by KirkWard — October 29th, 2010, 9:13 am
<?php
function my_s2_cron_job ()
{
if ($_GET["my_s2_cron_job"])
{
foreach (get_users_of_blog () as $user)
{
$user = new WP_User ($user->ID);
/**/
if (strtotime ($user->user_registered) <= strtotime ("-30 days"))
$user->add_cap ("access_s2member_ccap_30days");
/**/
if (strtotime ($user->user_registered) <= strtotime ("-60 days"))
$user->add_cap ("access_s2member_ccap_60days");
/**/
if (strtotime ($user->user_registered) <= strtotime ("-90 days"))
$user->add_cap ("access_s2member_ccap_90days");
}
exit ();
}
}
add_action ("init", "my_s2_cron_job");
?>
http://www.example.com/?my_s2_cron_job=1
OR: http://www.example.com/path/to/wordpress/?my_s2_cron_job=1
Statistics: Posted by Jason Caldwell — October 29th, 2010, 2:35 am
Statistics: Posted by KirkWard — October 26th, 2010, 11:44 am