2014-12-15 22:38:07 +02:00
|
|
|
<?php
|
2015-01-21 15:05:02 +02:00
|
|
|
|
2014-12-15 22:38:07 +02:00
|
|
|
/***
|
|
|
|
|
*** @checks if user can access the backend
|
|
|
|
|
***/
|
2017-07-26 14:57:52 +03:00
|
|
|
function um_block_wpadmin_by_user_role() {
|
2017-08-07 16:30:12 +03:00
|
|
|
if ( is_admin() && ! defined('DOING_AJAX') && um_user( 'ID' ) && ! um_user( 'can_access_wpadmin' ) && ! is_super_admin( um_user('ID') ) ) {
|
2015-01-03 15:31:15 +02:00
|
|
|
um_redirect_home();
|
2014-12-15 22:38:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
2017-07-26 14:57:52 +03:00
|
|
|
add_action( 'init', 'um_block_wpadmin_by_user_role', 99 );
|
2014-12-15 22:38:07 +02:00
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
*** @hide admin bar appropriately
|
|
|
|
|
***/
|
2016-02-24 15:44:19 +08:00
|
|
|
function um_control_admin_bar( $content ){
|
|
|
|
|
|
2016-02-26 22:19:18 +08:00
|
|
|
if( is_user_logged_in() ){
|
|
|
|
|
|
|
|
|
|
if ( um_user('can_not_see_adminbar') ){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-02-01 01:30:04 +02:00
|
|
|
|
2016-02-26 22:19:18 +08:00
|
|
|
return $content;
|
2014-12-15 22:38:07 +02:00
|
|
|
}
|
2017-11-02 18:13:50 +02:00
|
|
|
add_filter( 'show_admin_bar' , 'um_control_admin_bar', 9999, 1 );
|
2016-02-24 15:44:19 +08:00
|
|
|
|
2015-01-27 01:52:11 +02:00
|
|
|
/***
|
|
|
|
|
*** @fix permission for admin bar
|
|
|
|
|
***/
|
|
|
|
|
function um_force_admin_bar() {
|
|
|
|
|
um_reset_user();
|
|
|
|
|
}
|
2016-03-06 09:38:18 +07:00
|
|
|
add_action( 'wp_footer', 'um_force_admin_bar' );
|