Hello i have two custom role on my website (Freelancer and Employer) and i want after 1 year of registration the user have role Freelancer expire user.

This is what i want:

User subscribe > After 1 year change user role to subscriber > Wordpress send email to user role to invite contact admin to reset account > Admin of website after recive email change user role and resetting to Freelancer.

I find some solution to edit but i can't find the best. I try this plugin https://it.wordpress.org/plugins/expire-users/ (with i can setting the changing user role after expire time and setting send email to admin) but i can't setting valid only for user role Freelancer (and not for all).

Is possibile for you?

Different i try to edit this code (How to expire user registration?) to change user role after 1 year. But need setting for specific user and setting send email to user and admin. How can i do?

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' => '1 year ago',

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.