• Resolved sathiy

    (@sathiy)


    I want the login user to see only their report. How do I do that?

    Do I have to setup WP user group for the individual user and give a report that user group permission?

    Is there a way to give reports with user-level permission.

Viewing 1 replies (of 1 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    There are permissions based on user role for access to reports. There are no user specific permissions built into Exports and Reports, however you could add an action with PHP to ensure a limitation by the current user ID is utilized.

    The following code assumes that you have a “user” field defined in your report and filtering is enabled for it. It will always force the user filter value to be the current user ID and will override filter access.

    
    add_action( 'wp_admin_ui_pre_export', 'my_force_user_filter' );
    add_action( 'wp_admin_ui_manage', 'my_force_user_filter' );
    
    // Handle filtering of user for reports page.
    function my_force_user_filter() {
    
        // Filter only when on the reports page.
        if ( 'exports-reports' === $_GET['page'] ) {
            // Force the user filter to always be set.
            $_GET['filter_user'] = get_current_user_id();
        }
    
    }
    
Viewing 1 replies (of 1 total)

The topic ‘User security’ is closed to new replies.