XF 2.2 Conversion Question

Resurgence

New member
Hello. As I said in another thread, I'm migrating from vbulletin 4.2.x and I'm needing some clarification. For example in vBulletin, I used "$vbulletin->userinfo['usergroupid']" for user groups, what would be the syntax for xenforo?

Thanks,
 
Assuming you're trying to get the visitor's group ID (or check group membership)...

In PHP:
PHP:
$visitor = \XF::visitor();

$visitor->user_group_id // the primary group ID, almost always 2 (Registered)
$visitor->secondary_group_ids // an array of secondary group IDs
$visitor->isMemberOf([2, 3]) // test if visitor is in one of the passed group IDs

In a template:
HTML:
{{ $xf.visitor.user_group_id }}
{{ $xf.visitor.secondary_group_ids }}
{{ $xf.visitor.isMemberOf([2, 3]) }}
 
Assuming you're trying to get the visitor's group ID (or check group membership)...

In PHP:
PHP:
$visitor = \XF::visitor();

$visitor->user_group_id // the primary group ID, almost always 2 (Registered)
$visitor->secondary_group_ids // an array of secondary group IDs
$visitor->isMemberOf([2, 3]) // test if visitor is in one of the passed group IDs

In a template:
HTML:
{{ $xf.visitor.user_group_id }}
{{ $xf.visitor.secondary_group_ids }}
{{ $xf.visitor.isMemberOf([2, 3]) }}
Hey. I wanted to give you some further information. I have this currently for my xenforo script, which does work.

PHP:
$result = json_decode($curl_response, true);

if (isset($result['success']) && $result['success'] == true)
{
    if ($result['user']['can_view_profile'] == true)
    {
        $json = array ('status' => 'success');
        echo json_encode($json);
    }
    else
    {
        $json = array('status' => 'failed', 'message' => 'Your account is banned.');
        echo json_encode($json);
    }  
}
else
{
    $json = array('status' => 'failed', 'message' => 'Your username or password was incorrect.');
    echo json_encode($json, JSON_UNESCAPED_SLASHES);
}

Now, this is what I had for vbulletin, which I'd some help converting it:

PHP:
$result = verify_authentication($username, $password, md5($password), md5($password), '', false);
$response['message'] = "\#FFFF33You have entered an invalid username/password combination.\#. If you have forgetten your password, please visit https://swgresurgence.com/forums to reset your password.";
if($result != null){
    if($vbulletin->userinfo['usergroupid'] == 8){
        $response['message'] = "Your Account has been banned. Please contact Support Services for additional information.";
    }
    elseif($vbulletin->userinfo['usergroupid'] == 4){
        $response['message'] = "Your Account does not have a verified Discord Account. Please reach out to staff if you need assistance with verification.";
    }
    elseif($vbulletin->userinfo['usergroupid'] == 11){
        $response['message'] = "COPPA Accounts will not be activated until Parental Permission is received by Support Services. Please follow the directions that has been sent via email, or contact Support Services in order to activate your account.";
    }
    elseif($vbulletin->userinfo['usergroupid'] == 3){
        $response['message'] = "Your Account is not active. You must confirm your Email Address before your account can be activated.";
    }
    /*elseif($vbulletin->userinfo['usergroupid'] == 2){//block verified users
        $response['message'] = "\#FFCCCBThe Apotheosis Galaxy is temporarily locked for investigative maintenance. Please check back later.\#. \#DD1234^Bubba-Joe\#.";
    }
    elseif($vbulletin->userinfo['usergroupid'] ==  25){//staff only
      $response['message'] = "success";
    }*/
    elseif($vbulletin->userinfo['usergroupid'] == 2 || 25){ // allow staff and players
      $response['message'] = "success";
    }
}
echo json_encode($response);

I look forward to hearing from you.

Thanks,
 
Back
Top Bottom