Close the login page after the user logs in
wordpress Default Login page is: Http://WP directory/wp-login.php, login will automatically jump to: Http://WP directory/wp-admin. Now the question is, if the user is logged in, but it opens the wp-login.php page, what will happen? The answer is, WordPress will not do any processing, or directly to show you the login window:
The face of such a cold login box, users will be confused, I have not just been logged in? How do you want me to enter a username and password? So, after the user login, we should not let the user see the Login box again. There are two ways to resolve this problem:
Remove Login Link
Make sure that the wp-login.php link no longer appears on the page. If the user is not logged in, we can be prompted in this page:
After the user logs in, we remove the login and registration links above and replace them with the following:
This will not only allow users to have logged in at a glance, and will not mistakenly click wp-login.php into the login interface. PHP programming only needs to use the WordPress is_user_logged_in () function to judge whether the user has already logged in can realize.
wp-login.php do jump
Sometimes, users will accidentally click on the wp-login.php login link, such as the browser's address bar. We should do some remedial action at this time, do not let the login box appear in front of the user. The method introduced here is, when the user has logged in, but also open the wp-login.php link, we let him jump to the back page wp-admin, the specific method is, in the current topic functions.php Add the following PHP code:
function Redirect_logged_user () {
if (is_user_logged_in () && Empty ($_get[' action ') | | $_get[' action '] = = ' login ') {
wp_redirect (Admin_url ());
Exit;
}
}
Add_action (' Login_init ', ' redirect_logged_user ');
Create a custom column that is not visible to the user
If you are a plugin or a theme developer, you should often use custom columns (or custom fields) to store the relevant parameters for your plugin or theme, and interestingly, when you edit the page in WordPress background or use the The_meta () template function, WordPress does not display a custom column with a name that starts with an _ (underscore).
To some people do not want to let users see, but do not want users to modify the custom column, we can use this technique, not only to make the article edit the custom column of the page is simpler, and will not let users see unfamiliar custom columns and feel confused, or even random modification. Here is a sample usage:
<?php Add_post_meta (, ' _ludou ', ' Lulu blog ', true);?>
This adds a unique custom column named _ludou to the article with ID 68, which is the value of the blog, and is not visible to users in the article edit page. Normally, we might be using this so that we can see the Ludou field in the custom column of the article edit page:
<?php Add_post_meta (, ' Ludou ', ' Lulu blog ', true);?>
Additionally, when the value of a custom column is an array, the column is not visible to the user in the article edit page, even if the custom column name is not underlined before.