It is possible to limit who can see the:
- History Dashboard Widget
- History Page
- Settings page
You control this with filters. Below is an example that limits all above things to be only viewable by the users who has their email adresses specified in allowed_users.
Does this cover what you’re looking for?
// Allow only the users specified in $allowed_users to show the history page, the history widget on the dashboard, or the history settings page
add_filter("simple_history/show_dashboard_page", "function_show_history_dashboard_or_page");
add_filter("simple_history/show_dashboard_widget", "function_show_history_dashboard_or_page");
add_filter("simple_history/show_settings_page", "function_show_history_dashboard_or_page");
function function_show_history_dashboard_or_page($show) {
$allowed_users = array(
"[email protected]",
"[email protected]"
);
$user = wp_get_current_user();
if ( ! in_array( $user->user_email, $allowed_users ) ) {
$show = false;
}
return $show;
}
Great to learn that it is possible! Where do I put this code snipped? functions.php?
How can I modify it so that only the user with the name abc sees the simple history?
Yes, put it in your functions.php-file.
If you look at the documention for wp_get_current_user() you will all the fields it returns.
So you could replace the emails in the example with usernames instead, and then replace $user->user_email with $user->user_login. You could also user user_firstname to compare with the first name of the user, or user_lastname. To compare with the last name of the user. Pretty much everything is possible here 🙂
Wow, it works! Thanks a lot. Now I like this plugin even more. Outstanding support!!!