WordPres A way to restrict non-administrator access to the administration panel
introduction
The background path of Wordpress, an open source program, has been completely exposed and is vulnerable to hackers. Many other open source programs can be modified to set their own background address, and wordpress program background address is the domain name /wp-admin. In order to prevent non-administrators from logging in to the background, many webmasters can be said to have racked their brains. In the past, Xiaobian has also studied a method to prevent non-administrators from logging in to the background website by modifying the.htaccess rule. But it's a little more troubling than this article. Because you want to restrict the IP login of the other party, you must first obtain the IP address to do the restriction. Or you can know your own Ip address and define your own Ip. But it's just a little bit of trouble anyway. Xiaobian today to share with you a simpler method.
In order to increase the security of wordpress, we can restrict non-administrators from attempting to access the wordpress background administration panel. When they try to access, they will automatically jump to the homepage of the website, which is the best way for non-administrators to stay away from the wordpress background. It can be understood that only the administrator has permission to access the background.
The setting method is as follows
Add the following code to the functions.php file:
function restrict_admin_access(){ global $current_user; get_currentuserinfo(); if (! array_key_exists('administrator', $current_user->caps)) { wp_redirect( get_bloginfo('url') ); exit; } } add_action('admin_init', 'restrict_admin_access', 1);
Sum up
Well, that's all for this article, this method is when the non-administrator user who lands in the background of the site will automatically return to the home page of the site. I hope the content of this article can help you learn or use WordPress. If you have questions, you can leave messages and exchange messages.
Related article
-
How to notify administrators by email when a 404 error occurs on your WordPress site
This article mainly introduces the method of email notification administrator when 404 error occurs in WordPress site, which can realize the function of email notification administrator when 404 error occurs, which is very helpful to website optimization, and the friends who need it can refer to it2014-12-27 -
Guard wordpress theme with backdoor code to obtain administrator permissions
It only takes a few lines of code to leave a backdoor for a WordPress theme, so be careful2013-12-27 -
WordPress background address is changed so that you can not log in to the background simple solution
This article mainly introduces the simple solution to the failure to log in to the background due to the change of the background address of WordPress, and simply analyzes the reasons for the failure to log in to the background and the corresponding solutions, involving simple modifications to the wordpress configuration items2016-10-11 -
How does the MAC system change our blog theme through the Wordpress background
When using MAC to log in to the blog, Wordpress is the blog system we often use, the blog theme is too monotonous or do not like, the following teach you how to change our blog theme through Wordpress background, need friends can see2015-04-16 -
wordpress upgrade password correct background can not login solution
This article mainly introduces the solution to the failure to log in the background after the wordpress upgrade with the correct password, involving the modification of the cookie Settings in the system file after the upgrade, which has certain reference value, and the friends who need it can refer to it2014-12-31 -
A way to display comments associated with relevant user posts in the WordPress background
This article mainly introduces the method of WordPress background display related user articles associated comments, by adding custom function SQL calls to achieve the function of display related comments, very practical value, need friends can refer to it2014-12-25 -
WordPress background removes unwanted sidebar menu methods
This article mainly introduces WordPress background to delete unwanted sidebar menu methods, by adding custom functions combined with the corresponding menu items to delete unwanted menu items, in order to achieve the menu selection function, need friends can refer to the next2014-12-17 -
wordpress Background Opening slow solution (temporary)
wordpress background open slowly, there must be a lot of friends who encounter this problem, if you just want to temporarily solve it, you can refer to the following method, perhaps to help you2014-10-08 -
wordpress cannot log in to the background solution
wordpress3.4.1 Can not log in to the background solution, only need a simple 4 steps2013-11-10 -
wordpress background to add submenu commonly used several cases and corresponding methods
Add a submenu such as adding a submenu at the article, adding a submenu at the link, adding a submenu at the page, etc., this article lists several commonly used situations and corresponding functions, interested friends can refer to it, hope to help you2013-09-02
Latest comments