Opened 13 years ago
Closed 13 years ago
#2228 closed defect (bug) (worksforme)
Filtering Forum Permalink when buddypress support is enabled
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | trunk |
| Component: | API - Actions/Filters | Keywords: | |
| Cc: | brajesh@… |
Description
Hi,
upto bbpress 2.1.2(I have that version installed), It was possible to filter on forum/topic/reply permalinks when BuddyPress was active using the following code
function bp_change_group_forum_redirection(){
$group=groups_get_current_group();
if(!empty($group))
return;
$helper=bbpress()->extend->buddypress;
remove_filter( 'bbp_get_forum_permalink', array( $helper, 'map_forum_permalink_to_group' ), 10, 2 );
remove_filter( 'bbp_get_topic_permalink', array( $helper, 'map_topic_permalink_to_group' ), 10, 2 );
remove_filter( 'bbp_get_reply_permalink', array( $helper, 'map_reply_permalink_to_group' ), 10, 2 );
remove_action( 'template_redirect', array( $helper, 'redirect_canonical' ) );
}
add_action('bp_init','bp_change_group_forum_redirection',10);
That allowed to use the shared group forums as standalone forums too. When I was on group, the associated forum acted as group forum but on forums directory, It was acting as standalone forum.
I am testing bbpress 2.3.beta2 and the code is not working. It is understandable as the classes have changed.
The problem is, on the current setup, It is almost impossible to filter out the forums permalink unless you override this Group extension class BBP_Forums_Group_Extension
The problem is, overriding a class just for using permalink filtering may not be the best idea. Other than that, There is no entry point to filter the url.
I tried flipping the config using 'bbp_is_group_forums_active' hook but it is called too early and we can not determine which page we are viewing(It is called atleast one time before init action)
trying to filter like this
add_filter('bbp_get_forum_permalink','my_forum_link',20,2);
function my_forum_link($link,$id){
return get_permalink($id);
}
won't work too as you are already filtering on post_link,posttype_link and there is no way to remove those filters. Is there anyway to have a filter perhaps in 'maybe_map_permalink_to_group' to filter the forum permalink
Appreciate your thoughts on this.
Try hooking into 'bbp_buddypress_loaded' in /extend/buddypress/loader.php. That action is in place specifically to allow for extreme late binding or unbinding of the BuddyPress extensions actions and filters. If you need another intermediary action somewhere in the middle of the two, I can provide a few alternatives for you to try, that would lead to a core modification.