Jūs esate

ELGG. How to get group by its group name?

ELGG has method get_user_by_username(), which returns the object ElggUser. Unfortunately, there is no method called get_group_by_groupname(). So, I made one :) /** * Returns a group specified by its name * @param string $groupname The name of the group * @return mixed ElggGroup - if ElggGroup exists, false - otherwise */ function get_group_by_groupname($groupname) { global $CONFIG; $groupname = sanitise_string($groupname); $access = get_access_sql_suffix('e'); $row = get_data_row("SELECT e.* from {$CONFIG->dbprefix}groups_entity g join {$CONFIG->dbprefix}entities e on e.guid=g.guid where g.name='$groupname' and $access "); if ($row) { return new ElggGroup($row); } return false; } Good luck ;)

Komentuoti