WordPress.org

Ready to get started?Download WordPress

Forums

CollabPress
[resolved] Altering Project URL for Search Results (4 posts)

  1. astereo
    Member
    Posted 1 year ago #

    Hello,
    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:

    http://sitename.com/members/admin/projects/another-project

    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.

    Thanks!

    http://wordpress.org/extend/plugins/collabpress/

  2. Boone Gorges
    Moderator
    Plugin Author

    Posted 1 year ago #

    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 );
  3. astereo
    Member
    Posted 1 year ago #

    Seems to work perfectly!

    Thank you!

  4. Boone Gorges
    Moderator
    Plugin Author

    Posted 1 year ago #

    Awesome! Thanks for using CP/BP :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic