Current User Can on WPMU
-
Using below on a mu site (in functions.php of a child-theme in a site):
//Hide admin bar for all but admin if ( current_user_can( 'manage_options') ) { add_filter ('show_admin_bar', '__return_true'); } else { add_filter ('show_admin_bar', '__return_false'); } //if current user can manage options - therefore is admin, go to admin //page, else, go to a specific page if ( current_user_can( 'manage_options') ) { function go_tpn(){ wp_redirect( 'https://site.com/wp-admin/' ); exit(); } add_action('wp_login','go_tpn'); } else { function go_referral(){ wp_redirect( 'https:/site.com/page_slug/' ); exit(); } add_action('wp_login','go_referral'); } //redirect all on logout to home page add_action('wp_logout','go_home'); function go_home(){ wp_redirect( home_url() ); exit(); }
The admin part works as expected.
The logout part works as expected.
This does not:if ( current_user_can( 'manage_options') ) { function go_tpn(){ wp_redirect( 'https://site.com/wp-admin/' ); exit(); } add_action('wp_login','go_tpn'); } else {
The top part of the if fails as all users, even admin, are redirected to the page in the else.
What did I do wrong? Stumped. Is it due to being in WPMU? Is it due to using the add_action and not add_filter?
Cannot post url or provide login (would to a moderator here off site)
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘Current User Can on WPMU’ is closed to new replies.