Skip to:

Opened 2 years ago

Last modified 10 months ago

#8713 assigned defect (bug)

Group type meta is not set on group types registered in code

Reported by: sjregan's profile sjregan Owned by: dcavins's profile dcavins
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version: 10.3.0
Component: Groups Keywords: needs-patch


Group types may be registered in database via WP Admin (Groups -> Group Types), or registered via code using bp_groups_register_group_type(). Additional options or meta-data may be associated with group types via 'bp_get_group_type_tax_labels' and 'bp_get_type_metadata_schema' filters.

Regardless of how the group type is registered, the meta-data may be edited in WP Admin.

The group type objects returned from bp_groups_get_group_types() will have additional properties for the meta-data if the type has been registered in database via GUI, but group types registered via code will not have the additional object properties.

bp_groups_get_group_types() calls bp_get_taxonomy_types(), which does fetch the correct meta-data for group types registered via code, however it does not assign the fetched values to the final group type object. It does set the default group type properties from the database, just not meta-data properties registered via filters.

Steps to reproduce:

  • Register group type via Groups -> Group Types GUI.
  • Register another group type via bp_groups_register_group_type()
  • Add additional group type properties via 'bp_get_group_type_tax_labels' and 'bp_get_type_metadata_schema' filters
  • Observe both group types are visible in GUI and the additional properties can be saved and edited
  • Compare the differences in the properties on the objects returned by bp_groups_get_group_types()

In the following results from bp_groups_get_group_types (), group type 'house' is via code, and 'test' is via GUI. 'example_metadata_option' and 'another_example_metadata_option' are custom group type meta-data.

$types = {array} [2]
 house = {stdClass} [10]
  has_directory = "1"
  show_in_create_screen = "1"
  show_in_list = "1"
  description = "House"
  create_screen_checked = true
  labels = {array} [2]
   name = "Houses"
   singular_name = "House"
  code = true
  db_id = {int} 22
  name = "house"
  directory_slug = "house"
 test = {stdClass} [24]
  db_id = {int} 25
  labels = {array} [2]
   singular_name = "test"
   name = "tests"
  name = "test"
  has_directory = "1"
  directory_slug = "test"
  show_in_create_screen = "1"
  show_in_list = "1"
  example_metadata_option = "1"
  another_example_metadata_option = "1"

Change History (6)

#1 @imath
2 years ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to 11.0.0

Thanks for your feedback.

I'll have a look at it during 11.0 dev cycle.

This ticket was mentioned in Slack in #buddypress by imath. View the logs.

21 months ago

#3 @dcavins
21 months ago

  • Owner set to dcavins
  • Status changed from new to assigned

#4 @imath
19 months ago

  • Milestone changed from 11.0.0 to Up Next

#5 @imath
17 months ago

  • Milestone changed from Up Next to 12.0.0

#6 @imath
10 months ago

  • Keywords needs-patch added; needs-testing removed
  • Milestone changed from 12.0.0 to Awaiting Contributions
Note: See TracTickets for help on using tickets.