Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Solved] Function to detect user groups and poster user group

edited January 2012 in Vanilla 2.0 - 2.8

Is there a function or query to create a function to detect the logged in user group/role and the group/role of the person who wrote the post?


  • Options

    If theres a better way, please let me know -- but this is how I got it to work, using RoleBadges plugin code with a modification to spit out just the role I added .'post' to the end of it because im using it to create a rolepost css.

    function defineUser( $sender ) {
    $roles = array();
    $userModel = new UserModel();
    $roleData = $userModel->GetRoles( $sender->EventArguments['Author']->UserID );
    if( $roleData !== FALSE && $roleData->NumRows(DATASET_TYPE_ARRAY) > 0 )
    $roles = ConsolidateArrayValuesByKey( $roleData->Result(), 'Name' );
    foreach( $roles as $role ) {
    return $role.'post';

Sign In or Register to comment.