• Resolved edumusa

    (@edumusa)


    Hello,

    How can I display user’s email in the list, as our website uses this info to audit access?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Faiyaz Alam

    (@faiyazalam)

    hi @edumusa
    To display the user’s email in the list for auditing purposes, you can add the following code snippet to your theme’s functions.php file. This will display an email column in the list. However, please note that it will not add the email column to the CSV export as it is not possible to override this functionality at the moment.

    add_filter('faulh_admin_login_list_get_columns', 'faulh_admin_login_list_get_columns_custom');

    function faulh_admin_login_list_get_columns_custom($columns)
    {
    if (!isset($columns['cb'])) {
    return $columns;
    }
    $columns['email'] = 'Email';
    return $columns;
    }

    add_filter('manage_faulh_admin_custom_column', 'manage_faulh_admin_custom_column_custom', 10, 3);

    function manage_faulh_admin_custom_column_custom($value, $item, $column_name)
    {
    if ('email' == $column_name) {
    $user = WP_User::get_data_by('ID', $item['user_id']);
    if ($user instanceof \stdClass) {
    $value = $user->user_email;
    }
    }

    return $value;
    }
    Thread Starter edumusa

    (@edumusa)

    Hello @faiyazalam!

    Thank you very much for quick and efficient solution!

    I added: else { $value = ‘unavailable’;} as it was displaying an array of the other columns info.

    Great!

    Best regards!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.