Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Prohibit create groups with existing name

@henrywright

Moderator

Also should i be using the search_groups method for searching for an existing group with the same name or is there a different way?

BP_Groups_Group::search_groups() will get you a list of groups that match the first argument you pass to it. But the snag is, name and description matches are returned. We only want name matches.

An alternative would be to use BP_Groups_Group::group_exists( $slug ). This method will return either the ID of the group if one is found, else null. Keep in mind, the custom function you have hooked to groups_group_before_save will be passed the value of $slug.

Skip to toolbar