• Resolved arbremojo

    (@arbremojo)


    Hi,

    I would like to send an email to the user if the admin changed his role from role1 to role2. Is it possible?

    I saw on your doc we can create custom template. I could try this, but is there a function to get the previous role and the current role?

    Best regards,

    Clara.

Viewing 6 replies - 1 through 6 (of 6 total)
  • @arbremojo

    You can use this WP hook:

    /**
    		 * Fires after the user's role has changed.
    		 *
    		 * @since 2.9.0
    		 * @since 3.6.0 Added $old_roles to include an array of the user's previous roles.
    		 *
    		 * @param int      $user_id   The user ID.
    		 * @param string   $role      The new role.
    		 * @param string[] $old_roles An array of the user's previous roles.
    		 */
    		do_action( 'set_user_role', $this->ID, $role, $old_roles );
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @arbremojo,

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

    Thread Starter arbremojo

    (@arbremojo)

    @missveronicatv thank you for the answer!

    When should I “launch” the email sending? What should I do with this “do_action” ?

    @arbremojo

    You can try this UM User Role Change email custom template.

    https://github.com/MissVeronica/UM-Role-is-changed-email

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

    Thread Starter arbremojo

    (@arbremojo)

    Hi @missveronicatv !

    I’m sorry I never had the chance to thank you. The code you gave me works perfectly! I didn’t have time to test it before. My client is really happy.

    Thank you,

    Clara.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Send email on role changing’ is closed to new replies.