Is there way to notify admins by email on new subscribers/members?

I need my membership admins notified by email when I have new subscribers (so we can get them added to our print newspaper subscriptions, too). How can I do this?

  • Ash
    • WordPress Hacker

    Hello @soundpublishing

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

    You can use something like this:

    add_action('membership_payment_subscr_signup', 'send_email_to_admin', 10, 2);
    function send_email_to_admin($user_id, $sub_id) {
    	//Collect data whatever you want and send mail
    }

    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.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Please try the following code:

    add_action('membership_payment_subscr_signup', 'send_email_to_admin', 10, 2);
    function send_email_to_admin($user_id, $sub_id) {
    	$user = get_user_by( 'id', $user_id );
    	$sub = new Membership_Model_Subscription( $sub_id );
    
    	$subject = "A new user is subscribed";
    	$body = 'Hello Admin, A new user is subscribed in '. $sub->sub_name() .' plan. His name is '. $user->first_name . ' ' . $user->last_name .' and his email address is '. $user->user_email . '. Thank you.';
    	wp_mail( get_option( 'admin_email ' ), $subject, $body);
    }

    Let me know if it works.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.