• pls help me to check this login notifcation code

    i try inputting it but it did not work pls check and correct it

    add_action( 'wp_login', 'my_user_login_email', 10, 2 );
    
    function my_user_login_email( $user_login, $user ) {
    
     wp_mail( $user->user_email, 'Login Notification ' . $user_login, 'Dear $user_login, 
    
    We noticed a recent login to your STEPHEN EXCHANGE account with the following details:
    
    IP Address: 
    Date and Time:
    
    If this was you, you may ignore this message ??. If this wasn’t you, please log into your Stephen Exchange account immediately to change your password. We recommend you take the following steps:
    
    1: Click on the "MENU" and select "SETTING"
    
    2: Click on the Gear ?? in the right Conner on your profile picture and click on "MY ACCOUNT"
    
    3: scroll down and click on "CHANGE PASSWORD" put the current payment and the new password then confirm your new password and click on "UPDATE PASSWORD"
    
    We're always here to help if you need it. You can visit contact us via [email protected] for more information 
    
    Best,
    STEPHEN EXCHANGE TEAM ' . um_user_profile_url( $user->ID ) );
    }

    and help me to add the ip address of each user and date and time

    thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • @stephenbolu

    You can try this code snippet:

    add_action( 'wp_login', 'my_user_login_email', 10, 2 );
    
    function my_user_login_email( $user_login, $user ) {
    
        $time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
        $date_time = date_i18n( $time_format, current_time( 'timestamp' ));
        $headers = array( 'Content-Type: text/html; charset=UTF-8' );
    
        $message = "Dear " . esc_attr( $user_login ) . ",
        <br><br>We noticed a recent login to your STEPHEN EXCHANGE account with the following details:    
        <br><br>IP Address: " . esc_attr( um_user_ip()) .
        "<br>Date and Time: " . esc_attr( $date_time ) .
        "<br><br>If this was you, you may ignore this message ??. 
        <br>If this wasn’t you, please log into your Stephen Exchange account immediately to change your password. 
        <br><br>We recommend you to take the following steps:    
        <br>1: Click on the \"MENU\" and select \"SETTING\"    
        <br>2: Click on the Gear ?? in the right Corner on your profile picture and click on \"MY ACCOUNT\"    
        <br>3: Scroll down and click on \"CHANGE PASSWORD\" put the current password and the new password then confirm your new password and click on \"UPDATE PASSWORD\"    
        <br><br>We're always here to help if you need it. 
        <br>You can contact us via <a href=\"mailto:[email protected]\">[email protected]</a> for more information.    
        <br><br>Best,
        <br><a href=\"" . esc_url( um_user_profile_url( $user->ID )) . "\">STEPHEN EXCHANGE TEAM</a>";
     
        wp_mail( $user->user_email, 'Login Notification ' . esc_attr( $user_login ), $message, $headers ); 
    }
    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @stephenbolu Can you please not make duplicate topics again? It makes it harder for volunteers to support you when you do that.

    I archived that latest duplicate topic.

    Thread Starter stephenbolu

    (@stephenbolu)

    Okay thanks you guys are very helpful ????????

    Thread Starter stephenbolu

    (@stephenbolu)

    but when i login to my site i did not recevice any notifcation buy before am receing the login notifcartion

    @stephenbolu

    Install the “Check & Log Email” plugin and log and view all emails sent from WordPress.

    Note that many email clients considers emails where email from-address and to-address are equal to be spam.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wrong code’ is closed to new replies.