This topic has 3 replies, 3 voices, and was last updated 10 years by Abe.

  • Author
  • #8716
     gideon1210
    Participant

    Is there a way of setting up a email which is auto sent to a user once theyve signed up and after they’ve activated there account

    #8734
     Abe
    Keymaster

    add this code to sweetdate-child/functions.php and modify it for your needs:

    COPY CODE
    
    //send a welcome email when a user account is activated
    add_action('bp_core_activated_user','kleo_welcome_user_notification',10,3);
    function kleo_welcome_user_notification($user_id,$key=false,$user=false) {
        if(is_multisite())
            return ;// we don't need it for multisite
        //send the welcome mail to user
        //welcome message
        $welcome_email = __( 'Dear USER_DISPLAY_NAME,
     
    Your new account is set up.
     
    You can log in with the following information:
    Username: USERNAME
    LOGINLINK
     
    Thanks!
     
    SITE_NAME' );
        //get user details
        $user = get_userdata( $user_id );
        //get site name
        $site_name = get_bloginfo('name');
        //update the details in the welcome email
        $welcome_email = str_replace( 'USER_DISPLAY_NAME', $user->first_name, $welcome_email );
        $welcome_email = str_replace( 'SITE_NAME', $site_name, $welcome_email );
        $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
        $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
     
        //from email
        $admin_email = get_site_option( 'admin_email' );
     
        if ( empty($admin_email) )
            $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     
        $from_name = $site_name;//from
        $message_headers = "From: \"{$from_name}\" \n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
     
        //EMAIL SUBJECT
        $subject = sprintf(__('Welcome to  %1$s '), $site_name) ;
        //SEND THE EMAIL
        wp_mail($user->user_email, $subject, $welcome_email, $message_headers);
     
        return true;
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #14843
     Harvinder
    Participant

    Hi,

    Could you please break down the different section in this code, and tell me what the sections are used for?

    Also would i need to edit this in anyway?

    Thanks
    Harvinder

    #15114
     Abe
    Keymaster

    That is just an example and you need to edit it to match you needs. Try searching for a plugin that changes WordPress default emails. That code replaces the default activation email with the text you see there, “‘Dear USER_DISPLAY_NAME …”

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?