Last active
February 3, 2018 03:08
-
-
Save davidsword/57830718216224eae30d9b1ad97969cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('admin_init','HR_user_lockout'); | |
function HR_user_lockout() { | |
global $current_user, $menu, $submenu; | |
$restricted_user = 1; | |
// check for current user | |
if ($current_user->data->ID == $restricted_user) { | |
// remove admin menus | |
$menu = array(); | |
$submenu = array(); | |
// redirect user to only permitted page | |
add_action('current_screen','HR_user_redirect'); | |
} | |
} | |
function HR_user_redirect() { | |
$screen = get_current_screen(); | |
$permitted = 159; | |
if ( | |
// EDIT PAGE | |
( | |
$screen->base == 'post' && $screen->id == 'page' && | |
( | |
(!isset($_POST['post_ID']) && $_GET['post'] == $permitted) || | |
(isset($_POST['post_ID']) && $_POST['post_ID'] == $permitted) | |
) | |
) | |
OR | |
// MEDIA UPLOAD | |
( | |
$screen->base == 'upload' && $screen->id == 'upload' || | |
$screen->base == 'media' && $screen->id == 'media' || | |
$screen->base == 'async-upload' && $screen->id == 'async-upload' | |
) | |
) { | |
// HR user is in the right places | |
} else { | |
// redirect to permitted page | |
wp_redirect(get_bloginfo('wpurl').'/wp-admin/post.php?post='.$permitted.'&action=edit'); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment