Get a list of user groups a user is in with JS API?

Is there a better way of checking if a user is in a user group than using getChildren() for each user group as it takes too long to traverse the tree? JS API or otherwise

If it’s the current user you need to check, you can use getKeywordReplacements to evaluate the keyword (it doesn’t matter what asset_id you use as long as you have permission to access it).

js_api.getKeywordsReplacements({
	asset_id:'1234567',
	keywords_array:['%globals_user_member_groups%'], 
	dataCallback: (e) => console.log(e)
});

if it’s an arbitrary user, you can get it by username with validateActiveUser

js_api.validateActiveUser({
	username: 'JohnGill',
	get_groups: 1
	dataCallback: (e) => console.log(e)
});
1 Like