I'm preparing to transfer a suite of sites from individual Wordpress installations to WPMU and having trouble with a small piece of code.
I currently have a function that redirects to the home page any Subscriber trying to access the admin menus. Looks like this:
/*
* redirect subscribers to front page if they try to access wp-admin pages
*/
function redirect_subscribers() {
global $user_level;
if ($user_level == 0) {
wp_redirect(get_option('siteurl'));
}
}
add_action('admin_menu', 'redirect_subscribers');
Simple and it works, at least in the individual installations. In WPMU, however, the redirect sends the user to the parent url, ie http://www.mydomain.com/wpmu instead of http://www.mydomain.com/wpmu/blog_I_was_just_looking_at. The conditional checks out ok; the trouble seems to be in the redirect. It appears that the admin menu function pulls the user's primary blog data and replaces any variables in wp_redirect.
I've tried setting the variables both inside the function and outside (making sure to include it as a global of course) and I've tried various get_option, get_bloginfo and get_current_site calls with no success. I tried just creating a simple variable like $var = 'my_blog'
but even that won't pass in to the redirect. Hardcoding the url in that function does work.
What am I missing here? Or, is there a better way to accomplish keeping subscribers out of wp-admin?
Any thoughts or ideas appreciated.