Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7138 closed defect (bug) (fixed)

bp_groups_register_group_types() should fire on `'bp_init'`

Reported by: r-a-y's profile r-a-y Owned by: r-a-y's profile r-a-y
Milestone: 2.6.1 Priority: normal
Severity: normal Version:
Component: Groups Keywords: has-patch commit
Cc:

Description

See:
https://buddypress.org/support/topic/bp_groups_get_group_types-return-empty-array/#post-255085

The user is trying to register group types by pasting the example code from the codex into the theme's functions.php.

The problem is the code doesn't work in the theme's functions.php, but works in bp-custom.php.

This can be fixed by switching bp_groups_register_group_types() to run on 'bp_register_taxonomies' instead of 'bp_loaded'.

Attachments (3)

7138.01.patch (451 bytes) - added by r-a-y 9 years ago.
7138.02.patch (439 bytes) - added by r-a-y 9 years ago.
7138.2-7.patch (2.0 KB) - added by r-a-y 9 years ago.

Download all attachments as: .zip

Change History (11)

@r-a-y
9 years ago

#1 @imath
9 years ago

FWIW the user shouldn't use the functions.php of his theme but the bp-custom.php file to be sure to keep his group types ;)

I think there's a good reason why Boone chose bp_loaded. I remember he had to do this for the member types to be sure to be able to use it in bp_core_catch_uri. So i'd say i'm not sure it's a good idea to change this.

#2 @r-a-y
9 years ago

I think there's a good reason why Boone chose bp_loaded. I remember he had to do this for the member types to be sure to be able to use it in bp_core_catch_uri.

If that's the case, we should be able to run it at 'bp_init' at priority 1, so it runs just before bp_core_set_uri_globals().

Taxonomies are recommended to be registered on 'init' and not 'plugins_loaded'.

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


9 years ago

#4 @boonebgorges
9 years ago

I think there's a good reason why Boone chose bp_loaded. I remember he had to do this for the member types to be sure to be able to use it in bp_core_catch_uri. So i'd say i'm not sure it's a good idea to change this.

I don't remember this, but @imath might be right.

If that's the case, we should be able to run it at 'bp_init' at priority 1, so it runs just before bp_core_set_uri_globals().

This seems safest.

#5 @r-a-y
9 years ago

I took a look at the member types ticket and ticket:6286#comment:9 goes into a few specifics:

I've introduced the 'bp_register_member_type' hook. Member types must be registered here (instead of 'bp_init') in order to exist early enough to be detected during bp_core_set_uri_globals().

So it's the same as what we're talking about above.

2-7.patch is an idea for BP 2.7 to move post type and taxonomy registration above bp_core_set_uri_globals() and then we use 'bp_register_taxonomies' for group and member type registration.

For 2.6.1, let's go with 02.patch, which moves the hook to 'bp_init' at priority 1.

@r-a-y
9 years ago

@r-a-y
9 years ago

#6 @dcavins
9 years ago

  • Keywords commit added

#7 @r-a-y
9 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 10916:

Groups: Register group types on 'init'.

Previously, it was not possible to register group types in the current
theme's functions.php file.

This is due to our 'bp_groups_register_group_types' hook running on
'plugins_loaded'.

Commit moves the register group types hook to 'bp_init' at priority 1
so it runs just before bp_core_set_uri_globals(), which runs at priority
2.

Fixes #7138 (2.6-branch)

#8 @r-a-y
9 years ago

In 10917:

Groups: Register group types on 'init'.

Previously, it was not possible to register group types in the current
theme's functions.php file.

This is due to our 'bp_groups_register_group_types' hook running on
'plugins_loaded'.

Commit moves the register group types hook to 'bp_init' at priority 1
so it runs just before bp_core_set_uri_globals(), which runs at priority
2.

Fixes #7138 (trunk)

Note: See TracTickets for help on using tickets.