Your task is fairly simple given the tools that wordpress provides.
Step 1: The date/time a user registers an account at your site at is not naturally recorded by wordpress. You'd have to manually add such a functionality. It would make sense to save that to the wp_usermeta table.
Have a look the php time()
and the wordpress add_user_meta()
functions. Since the metadata would have to be written when the new user registers, you should trigger the timestamp adding with user_register
hook.
Step 2, Option 1: Compare current time to user registration time:
$reg_time = get_user_meta($user_id, 'reg_time', true); // dynamically insert user ID
$week = intval( ceil( ( time() - $reg_time ) / 604800 ) )
Step 2, Option 2: If you need more complex things to happen to the user on a weekly basis, you could schedule weekly events. That could be either done via cronjobs directly in the server's shell or via wordpress itsself.
For the latter option check out wp_schedule_event()
.
Since that natively supports only hourly, bi-daily and daily events, you'd have to add a custom recurrence:
function add_weekly_recurrence($schedules) {
$schedules['weekly'] = array(
'interval'=> 604800,
'display'=> __('Once Every Week')
);
return $schedules;
}
add_filter('cron_schedules', 'add_weekly_recurrence');
The scheduling of a new job should probably also be triggered by user_register
.
Step 3. Now that you have the user registration time as well as the ability compare time or schedule weekly events, you'd have to lastly write a function that actually defines what content is shown (and possibly gets scheduled). It would have to have the user ID as (one of its) argument(s) and, if you chose option 2, it should also increment the week/lesson, hence then you should probably store the user's current week/lesson number in the wp_usermeta table as well and make that a function parameter also.
Done.
Further reading:
Asides: I doubt weekly lessons are a good idea for any subject. I personally would hate not being able to go at my own speed and be restricted in my process, regardless of what I am taught.