var jQueryWeb357LoginAsUserCommunityBuilder = jQuery.noConflict();
jQueryWeb357LoginAsUserCommunityBuilder(function ($) {
    /**
    Community Builder: User Management
    */
    // Login as user button
    $(
        "body.com_comprofiler.view-showusers form[action='index.php'] table.table tbody"
    )
        .find('tr')
        .each(function () {
            var email = $(this).find('td').eq(7).text().trim();

            var build_login_as_user_url = login_as_user_url.replace(
                '{{email}}',
                email.trim()
            );

            $(this)
                .find('td')
                .eq(7)
                .after(
                    '<td><a target="_blank" class="btn" href="' +
                        build_login_as_user_url +
                        '">Login as <span class="loginasuser-email" style="font-weight:bold">' +
                        email +
                        '</span></td>'
                );
        });

    // Column
    $(
        "body.com_comprofiler.view-showusers form[action='index.php'] table.table thead"
    )
        .find('th')
        .eq(7)
        .after('<th>Login as User</th>');
});
