Automatic email when members permissions levels raised

My members don't get immediate access to my site, until they are verified and approved. I'd like to send an automatic email when members permissions levels are raised.

Can you tell me how to do this please?

Stephen O'Donnell

  • Ash
    • WordPress Hacker

    Hello @stephen_o_donnell0

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    Are you using any plugin to verify and approve the user? If yes, does it provide any action hook? If yes, only then this is possible.

    Would you please let me know about the approval procedure?

    Cheers
    Ash

  • stephen_o_donnell0
    • Design Lord, Child of Thor

    Hi, thanks for replying so quickly.

    I will be verifying members manually, by checking they qualify to be members, then upgrading their membership level to Full member (which gives them full access to all pages).

    I would like an automated notification sent to them to tell them they are now approved.

  • Ash
    • WordPress Hacker

    Hello @stephen_o_donnell0

    You can try the following code:

    add_action( 'membership_move_level', 'membership_move_level_cb', 99, 3 );
    function membership_move_level_cb( $fromlevel_id, $tolevel_id, $user_id ){
        if( $tolevel_id == 302 ){
            $user_info = get_userdata( $user_id );
            $to = $user_info->user_email;
            $subject = 'EMAIL SUBJECT';
            $body = 'EMAIL BODY';
            wp_mail( $to, $subject, $body );
        }
    }

    You need to modify the higher level id, subject and email text.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Note that, this will only work when you move to a level.

    Cheers
    Ash

  • stephen_o_donnell0
    • Design Lord, Child of Thor

    Hi Ashok, thanks for the reply.

    If I'm honest, I'm not entirely confident in adding that code. I know where the functions.php file, and would be happy to use this code, but I'm really not sure about the correct level id, or where I would add the message for the email.

    Could you explain a little more, or give an example of this in practise?

    Thank you.
    Stephen

  • Michael Bissett
    • Recruit

    Hey @stephen_o_donnell0, just jumping in for Ash here. :slight_smile:

    I'd like to take this one step further, and set this up for you, could you please send in the following:

    - Mark to my attention, the subject line should contain only: ATTN: Michael Bissett
    - Do not include anything else in the subject line, doing so may delay our response due to how email filtering works.
    - Link back to this thread
    - Include WordPress admin access details
    - Include FTP log-in details
    - Include the name of the Membership level you're approving users to
    - Include any relevant URLs for your site

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    https://premium.wpmudev.org/contact/

    Thanks a bunch, hope you're having a great weekend! :slight_smile:

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.