- Posts: 31
- Thank you received: 5
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
It would be nice to achieve this with an API call likeprivate function getUserGroupAttributeByUserGroupName($user_group_name, $attribute)
{
foreach ($this->api->getUserGroups() as $i => $group){
if($group === $user_group_name){
return $group[$attribute];
}
}
return NULL;
}
// survey level settings for plugin
public function beforeSurveySettings()
{
$current_user_uid = $this->api->getCurrentUser();
$admin_ugid = $this->getUserGroupAttributeByUserGroupName('Admin', 'ugid');
$user_is_admin = $this->api->getUserInGroup($admin_ugid, $current_user_uid);
$admin_group_owner_id = $this->getUserGroupAttributeByUserGroupName('Admin', 'owner_id');
if(!is_null($user_is_admin) || $current_user_uid == $admin_group_owner_id){
// Only these users can access this block:
// - users in Admin user group
// - Admin user group owner
}
}
if( in_array('Admin', $this->api->getUserRoles($current_user_id)) ) { // code here }
Please Log in to join the conversation.
Sincerely,It would be nice to achieve this with an API call like
Code:if( in_array('Admin', $this->api->getUserRoles($current_user_id)) ) { // code here }
Please Log in to join the conversation.