I have a membership wordpress site. I want to suspend user after sixth month from the registration date. So that user purchase our plan/subscription. I want everything without any plugin.

How can i do this?

  • You have to create a plugin to do this. You cannot have that without plugin.
    – mmm
    Nov 16, 2017 at 11:56

1 Answer 1


You would need to do a Cron. Get all user who where registered before 6 months ago and change their role to something else. in this example i have user 'expired' but you would need the create this role before you could use it.

add_action('wp', function() {
   if ( !wp_next_scheduled( 'check_for_expired_users' ) ) {
      wp_schedule_event( time(), 'daily', 'check_for_expired_users');

function check_for_expired_users() {
  $users = get_users([
    'role__not_in' => array('expired'),
     'date_query' => array(
         'before' => '6 months ago',

  foreach ($users as $u) {
    $u->set_role( 'expired' );


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.