WordPres A way to restrict non-administrator access to the administration panel

Published: 2016-12-19 17:13:18 Author: Anonymous I want to comment
You may find that when the front-end user center is implemented, the background control panel loses its role, so it is necessary to restrict other users to enter the background control panel! So what are we going to do? After the method shared in the following article, only the administrator can enter, otherwise other registered users will jump to the home page. Let's take a look.

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.

  • Tag: WordPres administrator management panel

Related article

Latest comments