Share a PHP script instance for email reminders during guest login in WordPress

Source: Internet
Author: User
This article mainly introduces the PHP script instance sharing for email reminders for visitor login in WordPress, similar to the remote IP login reminder of social networking websites, however, the IP address display is not in the scope of this article. For more information, see Logon email reminder implementation method
The premise is that the space has the email function. to test whether the email function is available, click "forgot password" on the logon page. if you send an email to your mailbox, the email function is available.

1. logon success reminder
Just like a bank logon reminder, if someone logs on to the system, an email will be sent to remind you that someone has logged on. if you didn't log on, you should be vigilant. Put the following code into the topic's functions. php:


/*************************************** * ************* Function name: wp_login_policy v1.0 by DH. baihua. function functions: if you log on to the wp background, you will receive an email notification to the blogger ****************************** * **********************/function wp_login_y Y () {date_default_timezone_set ('prc'); $ admin_email = get_bloginfo ('admin _ email '); $ to = $ admin_email; $ subject = 'Your blog space logon reminder '; $ message ='

Hello! Your blog space ('. get_option ("blogname").') has been logged on!

'.'

Please be sure to log on by yourself to prevent attacks from others! The logon information is as follows:

'.'

Login name: '. $ _ POST ['log'].'

'.'

Logon Time: '. date ("Y-m-d H: I: s ").'

'.'

Logon IP address: '. $ _ SERVER ['remote _ ADDR'].'

'; $ Wp_email = 'no-reply @'. preg_replace ('# ^ www \. # ', '', strtolower ($ _ SERVER ['server _ name']); $ from =" From :\"". get_option ('blogname '). "\" <$ wp_email> "; $ headers =" $ from \ nContent-Type: text/html; charset = ". get_option ('blog _ charset '). "\ n"; wp_mail ($ to, $ subject, $ message, $ headers);} add_action ('WP _ login', 'WP _ login_policy ');

2. logon failure reminder
If someone tries to log on to your system but fails, such repeated attempts must be recorded and sent to the blogger. in this way, if a wrong logon occurs, an email will be sent to your mailbox, and the login name and password tried by the other party will be sent to your mailbox. Put the following code into the topic's functions. php:

/*************************************** * ************* Function name: wp_login_failed_policy v1.0 by DH. baihua. function functions: if an error occurs, log on to the wp background and email the blogger ***************************** * **********************/function wp_login_failed_policy () {date_default_timezone_set ('prc'); $ admin_email = get_bloginfo ('admin _ email '); $ to = $ admin_email; $ subject = 'Your blog space logon error alerts '; $ message ='

Hello! Your blog space ('. get_option ("blogname").') has a logon error!

'.'

Please make sure your login error is yours to prevent attacks from others! The logon information is as follows:

'.'

Login name: '. $ _ POST ['log'].'

'.'

Logon password: '. $ _ POST ['pwd'].'

'.'

Logon Time: '. date ("Y-m-d H: I: s ").'

'.'

Logon IP address: '. $ _ SERVER ['remote _ ADDR'].'

'; $ Wp_email = 'no-reply @'. preg_replace ('# ^ www \. # ', '', strtolower ($ _ SERVER ['server _ name']); $ from =" From :\"". get_option ('blogname '). "\" <$ wp_email> "; $ headers =" $ from \ nContent-Type: text/html; charset = ". get_option ('blog _ charset '). "\ n"; wp_mail ($ to, $ subject, $ message, $ headers);} add_action ('WP _ login_failed ', 'WP _ login_failed_policy ');

The result is shown in. a logon location is followed by a query using qqwry. dat.

Modify the background logon address
Plug-in method
Many plug-ins can implement such functions, such as Protected wp-login and Stealth Login Page. you just need to download and install them directly.

Code method
If you do not want to use the plug-in, copy the following code to the functions. php file of the current topic:

// Protect the background login function login_protection () {if ($ _ GET ['word']! = 'Fuck') header ('Location: http://blog.gimhoy.com/');} add_action ('login _ enqueue_scripts', 'login _ protection ');

So only open http: // siteurl/wp-login.php? Word = fuck, will open the login page, otherwise it will automatically jump to the http://blog.gimhoy.com/

But after the blogger, The Mailbox still receives a lot of logon failure reminders every day, so take a simpler and more crude method: modify the wp-login.php file name

For example, changing a wp-login.php to a gimhoy-login.php, but also opening this file, replace all the wp-login.php inside with a gimhoy-login.php. In this way, the login address becomes http: // siteurl/gimhoy-login.php. combined with the previous method, it becomes http: // siteurl/gimhoy-login.php? Word = fuck.

Simple and crude, achieving the goal.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.