XF 2.0 Select a list of members by specific custom fields

gotski

Active member
Licensed customer
Hello, please tell me where to find the solution to display the list of users sorting them by custom fields, I will be grateful for any hint.
 
Sorting by a custom field? That would likely require custom development. You can do some searches for users by custom fields in the control panel though.
 
Sorting by a custom field? That would likely require custom development. You can do some searches for users by custom fields in the control panel though.

I needed a list of users for my add-on sorted by specific customfield, the solution to the my problem I found in src\XF\Searcher\User.php in protected function applySpecialCriteriaValue

I got my list of users

$CustomField = array('CustomField_name'=>'CustomField content');
$searcher = $this->searcher('XF:User', ['user_field' => $CustomField]);
 
Sorting by a custom field? That would likely require custom development. You can do some searches for users by custom fields in the control panel though.

Mike, if I sort members by two custom fields, I received all members who has at least one of the specified custom fields, I need a list of those who have both fields. Perhaps you have ideas, how can I find a solution?

$searchFields = array('CustomField1'=> $CF1 content, 'CustomField2'=> 'CF2 content');
$searcher = $this->searcher('XF:User', ['user_field' => $searchFields]);
 
Back
Top Bottom