We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2249
    • 60 Posts
    Hi All

    I am trying to determine a users usergroup using the following code. But when i print the result all i get is Resource id #26.
    Can anyone see what i might be doing wrong here?

    Hers my code:


    $user_arr = $modx->userLoggedIn();
    $web_group = $modx->db->select("webgroup", $modx->getFullTableName(’web_groups’), "webuser=’".$user_arr[id]."’");
    print $web_group;

    Thanks
    Ash
      • 10487 MODX Staff
      • 1,535 Posts
      You need to loop through the recordset to get the actual data - try this:
      $groups = array();
      $user_arr = $modx->userLoggedIn();
      $web_group = $modx->db->select("webgroup", $modx->getFullTableName('web_groups'), "webuser='".$user_arr['id']."'");
      if ($modx->db->getRecordCount($web_group) > 0) {
      	while ($row = $modx->db->getRow($web_group)) {
      		$groups[] = $row['web_group'];
      	}
      }
      print_r($groups);
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 2249
        • 60 Posts
        Works, Thanks very much.

        Ash