• Resolved Metasequoia

    (@metasequoia)


    hi,

    i use this plugin and i live it very much. i have one suggestion/ feature request: would be cool to have the possibility to only show this simple history to certain users (e.g. admins) or to choose users which can see the plugin from a dropdown list.
    any chance to see this in a future version?

    keep up the good work!

    greets

    martin

    https://ww.wp.xz.cn/plugins/simple-history/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Pär Thernström

    (@eskapism)

    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;
    
    }
    Thread Starter Metasequoia

    (@metasequoia)

    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?

    Plugin Author Pär Thernström

    (@eskapism)

    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 🙂

    Thread Starter Metasequoia

    (@metasequoia)

    Wow, it works! Thanks a lot. Now I like this plugin even more. Outstanding support!!!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘feature request: Show log only to certain users’ is closed to new replies.