After logging on to WordPress, close the login page and set the invisible topic for users. after logging on to wordpress, _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
After logging on to WordPress, close the logon page and set invisible topics for users. after logging on to wordpress. After logging on to WordPress, close the logon page and set the invisible topic for users. after logging on to wordpress, close the logon page. the default logon page for WordPress is: after logging on to WP-WordPress in the wp Directory, close the login page and set invisible topics for users. after logging on to wordpress

Close the logon page after logon.
WordPress default login page is: http: // WP directory/wp-login.php, will automatically jump to: http: // WP directory/wp-admin after login. Now the problem is, if the user has logged on, but it opens the wp-login.php page again, what will happen? The answer is that WordPress will not do anything, or directly display the logon window to you:

In the face of such a cold login box, users will be confused. have I logged on just now? Why should I enter the user name and password? Therefore, after a user logs on, we should not allow the user to see the logon box again. There are two solutions to this problem:

Remove logon link

Make sure that the link to the wp-login.php no longer appears on the page. If the user does not log on, the following prompt is displayed on the webpage:

After a user logs on, we will delete the above logon and registration links and replace them:

This not only gives users a clear picture of whether they have logged on, but also does not mistakenly click the wp-login.php to enter the login interface. For PHP programming, you only need to use the is_user_logged_in () function of WordPress to determine whether the user has logged on.

Wp-login.php jump

Sometimes, the user will accidentally click on the wp-login.php login link, such as the address bar of the browser. At this moment, we should do some remedial measures. do not make the logon box appear in front of the user. The method introduced here is that when the user has logged on, but opened the wp-login.php link, we let him jump to the background Home Page wp-admin, the specific method is in the current topic functions. add the following php code to php:

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 custom columns invisible to users
If you are a plug-in or topic developer, you should often use custom columns (or custom fields) to store parameters related to your plug-ins or themes. Interestingly, when the post editing page in the WordPress background or the the_meta () template function is used, WordPress does not display custom columns whose names start with _ (underline.

We can use this technique for custom columns that do not want users to see or modify, not only to make the custom columns on the document editing page simpler, it will not confuse users with unfamiliar custom columns, or even modify them randomly. The following is an example:

<? Php add_post_meta (68, '_ ludou', 'pandoublog', true);?>

In this way, an article named _ ludou with the id of 68 is added, and the value is the unique custom topic of the blog with the name of "lu dou", which is not displayed on the article editing page. In general, we may use this method. in this way, you can see the ludou field in the Custom section on the article editing page:

<? Php add_post_meta (68, 'udou', 'pandoublog', true);?>

In addition, when the value of a custom column is an array, this column is invisible to users on the article editing page, even if the name of the custom column is not underlined.

Articles you may be interested in:
  • Share a PHP script instance for email reminders during guest login in WordPress

The default WordPress logon page is: http: // WP directory/wp -...

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.