Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Make user selection configurable (displayed field) + ajaxify it #294

Open
tlartaud opened this issue Jan 30, 2018 · 4 comments
Open

Make user selection configurable (displayed field) + ajaxify it #294

tlartaud opened this issue Jan 30, 2018 · 4 comments

Comments

@tlartaud
Copy link
Contributor

See https://wp-customerarea.com/support/topic/problem-adding-users-to-a-group/

@tlartaud tlartaud changed the title Need usernames is Select2 users lists Need usernames in Select2 users lists Jan 30, 2018
@vpratfr
Copy link
Member

vpratfr commented Jan 30, 2018

User selection needs some work all over the plugin.

In this case, we are missing a filter to allow customizing the user list (that would allow to show something else than the display name)

customer-area-extended-permissions\src\php\user-group\user-group-admin-interface.class.php line 199

BUT

We also need to allow picking a user using an Ajax search: our current approach starts causing problems when there are a few hundreds of users (page time is too long).

So we need to think about this issue in the next release. Ideally, user selection will be made standard (one single access point for the whole plugin): use ajax whenever there is a select2 for user (owners, admin filter, switch users, groups, projects, etc.)

@vpratfr vpratfr changed the title Need usernames in Select2 users lists Make user selection configurable (displayed field) + ajaxify it Jan 30, 2018
@vpratfr
Copy link
Member

vpratfr commented Feb 26, 2018

@tlartaud

Would be nice to add a post snippet to show how to customize the way owners are displayed. For example, show email instead of display_name for users.

###How to do that?

use the filter: cuar/core/ownership/owner-display-name?owner-type={{owner_type}} where {{owner_type}} is one of usr, grp, mgrp, prj, rol, sgrp, glo

The function used by the filter receives the default value and the owner id as parameters.

For instance (not tested):

function cuar_change_user_display_info($default, $id) {
    $user = new WP_User($id);
    return $user->email;
}
add_filter('cuar/core/ownership/owner-display-name?owner-type=usr', 'cuar_change_user_display_info', 10, 2)

@vpratfr vpratfr closed this as completed Feb 26, 2018
@vpratfr
Copy link
Member

vpratfr commented Feb 26, 2018

Fixed

@vpratfr vpratfr removed their assignment Feb 26, 2018
@vpratfr vpratfr reopened this Feb 26, 2018
@vpratfr
Copy link
Member

vpratfr commented Feb 26, 2018

Reopened until @tlartaud creates the code snippet

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants