How to get all users with specific entity type

Pastoral Juvenil Aveiro Posted in General Discussion 2 months ago

Hello, sorry for my English, it's not my native language.
I would like to now if it's possible to download a list of the users that belong to a specific user category set with the [Ossn Component]User Categories. Maybe an update to the https://www.opensource-socialnetwork.org/component/view/850/users-to-cvs, where we could also have the user category specified (if the component is installed).

Thank you in advance!

Replies
German ~Z~ Man Replied 2 months ago

If you have a look into generate.php you'll find that it's making use of the searchUsers() method. Currently - without any additional parameters - this method simply returns ALL users. But if you have a look into OssnUsers.php, starting at line 625 you'll find that the search result can be in fact refined by what Arsalan named 'entities_pairs' which may be passed when calling the searchUsers method.
Thus, in case you want to generate a list of female users only for example, you would need to change the method call like

$users = $users->searchUsers(array(
                'page_limit' => false,
                'entities_pairs' => array(
                    'key_1' => array ('name' => 'gender', 'value' => 'female')
                )
    ));

Since I've never used the categories component myself, I don't know the exact name of the entity. So just have a look into your entities database and list all entities of type 'user' and find the right subtype yourself.