Support » Plugin: CollabPress » Altering Project URL for Search Results

  • Resolved astereo


    I’ve successfully integrated the CP custom post type into a unified BuddyPress search, but my remaining hurdle remains getting the project links to point to the appropriate places. Currently they are taking on the post author user name (cp-bp.php shows it will take this as the default when it’s creating it’s permalinks), so it looks something like this:

    I’ve looked over the cp-bp-groups file where it creates the additional filter to change the slug to being group based, but unfortunately this is a bit over my head and I can not figure out how to hook it all together so that outside of a group page (ie: from the search results) I can hook the projects to the group they belong with and get the appropriate permalink.

    Any help would be appreciated.


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Boone Gorges


    The heavy lifting is done in includes/cp-bp-groups.php, in the method rewrite_item_parent(). This filter modifies the “parent” of the project in question, swapping it from the default member to a group, which then affects the permalinks generated in cp-bp.php.

    By default, this filter is only applied in the group context (see line 141, add_filter( 'cp_bp_get_project_permalink_parent_item', array( &$this, 'rewrite_item_parent' ), 10, 2 );). You should theoretically be able to build a more general wrapper for it, though the peculiarities of how BP_Group_Extension objects are registered might make it a little complicated. I haven’t tested it, but something like this should work:

    function bbg_cp_group_permalink_filter( $args, $item ) {
        $extension = new CP_BP_Group_Extension;
        return $extension->rewrite_item_parent( $args, $item );
    add_filter( 'cp_bp_get_project_permalink_parent_item', 'bbg_cp_group_permalink_filter', 20, 2 );

    Seems to work perfectly!

    Thank you!

    Plugin Author Boone Gorges


    Awesome! Thanks for using CP/BP 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Altering Project URL for Search Results’ is closed to new replies.