Files
ultimatemember/includes/core/um-actions-wpadmin.php
T

40 lines
838 B
PHP
Raw Normal View History

2014-12-15 22:38:07 +02:00
<?php
2017-12-18 15:36:04 +02:00
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
2018-02-12 00:56:01 +02:00
/**
* Checks if user can access the backend
*/
function um_block_wpadmin_by_user_role() {
if ( is_admin() && ! defined( 'DOING_AJAX' ) && um_user( 'ID' ) && ! um_user( 'can_access_wpadmin' ) && ! is_super_admin( um_user( 'ID' ) ) ) {
um_redirect_home();
2014-12-15 22:38:07 +02:00
}
2018-02-12 00:56:01 +02:00
}
add_action( 'init', 'um_block_wpadmin_by_user_role', 99 );
2016-02-26 22:19:18 +08:00
2015-02-01 01:30:04 +02:00
2018-02-12 00:56:01 +02:00
/**
* Hide admin bar appropriately
*
* @param $content
*
* @return bool
*/
function um_control_admin_bar( $content ) {
2018-05-31 13:14:21 +03:00
if ( is_user_logged_in() && um_user( 'can_not_see_adminbar' ) ) {
return false;
2015-01-27 01:52:11 +02:00
}
2018-02-12 00:56:01 +02:00
return $content;
}
add_filter( 'show_admin_bar' , 'um_control_admin_bar', 9999, 1 );
/**
* Fix permission for admin bar
*/
function um_force_admin_bar() {
um_reset_user();
}
add_action( 'wp_footer', 'um_force_admin_bar' );