The file functions.php
is not the place to run this kind of code. See Where do I put the code snippets I found here or somewhere else on the web?
You can use a Must Use plugin or make a simple one and Network Activate.
It would go like this:
<?php
/* Plugin Name: Only admins on dashboard */
add_action( 'admin_init', 'admin_ban_wpse_105863' );
function admin_ban_wpse_105863()
{
if( !current_user_can( 'activate_plugins' ) ){
wp_redirect( site_url() );
exit;
}
}
The documentation for the function get_bloginfo
has recommended alternatives for many cases. The site_url
function takes care of using the current blog URL.
[update]
The only place where the error message ...permissions to access...
appears is in the file wp-admin/includes/menu.php
. And it has an useful hook:
add_action( 'admin_page_access_denied', 'denied_ban_wpse_105863' );
function denied_ban_wpse_105863()
{
wp_redirect( site_url() );
exit;
}
Related Posts:
- Create mobile site with same content just different theme
- How to hide or remove unwanted widgets on Multisite installation?
- How can I diagnose a slow WordPress admin?
- How to enable a site administrator to edit users in a WordPress network/ multisite setup?
- WP-Admin not working properly at WordPress multisite with subdirectories
- Security in WordPress plugin development
- Hide a theme on list of themes in wp-admin without editing core files
- Difference Between Admin and Super Admin in Database
- wp-admin slow in multisite
- Don’t allow access to wp-admin but allow admin-ajax requests to be fulfilled on frontend?
- Timeout While Upgrading Network in Multi-site
- Uploading Images to Multi-Site Causes Failure to HTTP Error
- Multisite wp-admin redirect loop
- WordPress network (multisite) /wp-admin/ redirect loop (ERR_TOO_MANY_REDIRECTS)
- Copy posts from one blog to another in multisite environment
- My subsites accidentally went from one multisite network to another. How do I change it back?
- Redirect loop (only for multisite network admin)
- Manipulate list of themes in wp-admin
- Creating a Post form outside of the Admin
- Subsites in Multisite installation throwing 404 error on wp-admin in IIS 7
- How to remove Broken Link Checker widget from admin menu
- How to set Active plugins as the default screen?
- Why can’t I delete original user in multisite? Options for manual removal
- Multisite network admin – URL / redirect error
- Cookie nonce is invalid – Multisite
- WordPress mutisite migration
- Why does the My Site dropdown show only a single domain?
- Super admin access to a forgotten WP instance?
- Iframe being removed only for some users when publishing a page
- 2 website 1 database… Local to online
- Moving wp-admin folder to a different host in a multisite environment
- Site’s admin created with wpmu_create_blog accessible only on 2nd attempt
- Is There A Plugin to Create WP Multisite Installs programatically
- Can’t log in to wp-admin after setting up Multisite
- Infamous admin login redirect
- WordPress multisite second site admin resulting in too many redirects error
- Multisite wp-admin redirecting to main wp-admin using NGINX
- WordPress Multisite: Login to all subsites at once
- How to Add Super Admin for WordPress multi-site
- network admin pages not linked to correctly
- Multisite – cannot remove specific sub-menu its parent menu. All sub-menus disappear
- How to have same admin login for more than one site?
- WP Admin Panel for Multi-site install not loading JavaScript for one Subdomain
- Backend freezing on certain pages of a subsite
- Admin user getting redirected to /wp-admin/user
- Pages redirect me to the homepage
- Many big issues in the website, WP_Debug not showing
- What could be changing my WP password and blocking plugins from installing?
- Site admin in a network install can’t edit users?
- Multisite – sub-subfolders for certain blogs
- Multisite behind Varnish
- How do I know if a user has a blog in WordPress Multisite?
- Configure WordPress to read from database only, never write
- How to migrate WordPress Blogs into Multisite without using the GUI-Import/Export Feature
- Suppress subdirectory from WordPress Multisite primary URL
- Has anyone experience w/ WordPress (MultiSite) hidden users (possibly hacked)?
- Why wordpress multisite redirect to wp-signup if site exists?
- Is the W3 Total Cache plugin a good choice for WordPress MultiSite? [closed]
- Is it possible to import a wordpress backup from a single site in to a multi-site configuration?
- Multiple domains with different child themes on one installation?
- Changing wp-content to other name? Multisite set up
- Redirect users on logout
- Multisite: I have a gap in my blogs. How to add the missing one?
- Create rewriterules for different domains in htaccess file with WP multisite
- Force Load https WordPress Plugins
- Multi-Site Subdomain: Show master site under subdomain if no sub site exists
- Register existing user on another site in a multisite network?
- Can i import a site (plugins, database, images) etc. Into an existing wordpress multisite?
- Importing XML didn’t finish, site is now inaccessible
- WordPress multisite – Bitnami
- One blog inside another
- Change Default WordPress MU Blog
- wordpress multisite permalink structure: mostly subdomains but not all
- Bulk Move Users from one site to another within a network ( Multisite )
- Multisite – getting a 404 for additional site created using subdomain install
- how to create wordpress network with multiple wordpress installations
- Multiple sites with independent users
- Programmatically creating site in a network
- What happens when someone goes to the root URL in WordPress Multisite?
- Migrate single site to Multisites with plugins, cPanel and already working subdomains
- how to install wordpress HyperDB
- Multisite Redirect for Home Page Only
- Change language for each website using multisite
- Cannot see dropdown shortcut to site dashboard in WordPress network why?
- Automatic creation of mutisite blog outside of the admin
- Automatically add a registered user on the wordpress multisite network even to just one other site
- Redirecting specific sites to HTTP in WordPress Multisite
- WordPress Multisite VMware copy for dev use not allowing loggin
- Multisite,half the way
- Create new multisite from existing and keep domain?
- Admin Ajax returns “0 200 OK server error..” in Multi-site sub-site
- WordPress Multisite: an official and definitive way to enable https ? (http to https)
- Synchronize wordpress site between two different servers
- What dictates whether a plugin will be available to a site in a multisite install?
- How do I setup WordPress Multisite in it’s own directory?
- How do I remove ‘www.’ from all internal links in self-hosted multisite?
- How do I make a copy of WordPress to other folder
- Add custom fields in the new and edit the site forms without touching the WP core
- WordPress multisite with subdirectories always redirects to mainsite
- WordPress Multisites