#7138 closed defect (bug) (fixed)
bp_groups_register_group_types() should fire on `'bp_init'`
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| 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)
Change History (11)
#2
@
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
@
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
@
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.
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.