Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] BuddyPress incorrectly redirects to BBPress forum within group


  • notpoppy
    Participant

    @notpoppy

    I suspect this is one of those problems a BuddyPress database ninja could solve very easily, so here goes…

    I added BBPress forums to my existing BuddyPress set-up a while ago. Previously I had forums within my groups, and I wanted to retain that structure. After installing BBPress I configured each of my groups to have the appropriate forum.

    This has worked as desired for all of them with one exception. I accidentally associated one group with the wrong forum. Although I later corrected it, the group is not working as the others do:

    • If I post a thread in the group, it appears in the wrong forum.
    • If I click on a thread within the forum, it sends me to the same wrong forum
    • If I inspect the forum via the admin, the permalink still refers to the wrong forum (and is not editable)

    I’ve spent a few hours trying to track what’s happening in the database but I can’t find anything wrong.

    What I have found is that if I locate my forums in wp-posts, the links to all of them appear in the following format:

    mysite.com/forums/forum/name-of-forum/

    When I try to access that link for one of the group forums which are working correctly it redirects as follows:

    mysite.com/groups/name-of-forum/forum

    But when I do the same for the faulty forum, it redirects to the wrong place as follows:

    mysite.com/groups/name-of-wrong-forum/forum

    It seems to me that BuddyPress is not recognising that this one group should redirect to a different forum and I don’t know how to change that. I have tried using the ‘Repair BuddyPress Group Forum relationships’ under Tools > Forums, to no avail.

    Disabling plugins other than BBPress and BuddyPress has no effect. Disabling BuddyPress ‘fixes’ the problem, in that the forum behaves correctly again, but obviously this is not the solution I’m looking for!

    If anyone can help me crack this I’d be very grateful. I’m happy to make the change direct in the database if necessary (I’m running this as a test site in an offline environment at the moment). I’m using WP 3.9.1, BBP 2.5.4 and BP 2.0.1.

Viewing 17 replies - 1 through 17 (of 17 total)

  • notpoppy
    Participant

    @notpoppy

    Still trying to sort this out. I’ve tried searching in the database for parts of the URL it’s redirecting to but I can’t seem to find anything which seems to be causing the problem. Would really appreciate help with this.

    It looks like there is a bug in bbPress’ repair tool 🙁

    If you grab the bbPress forum ID e.g. 25

    Open up wp_bp_groups_groupmeta

    You should see something similar to this:

    
    id	group_id	meta_key	meta_value	
    1	1	total_member_count	2
    2	1	last_activity	2014-06-26 00:37:33
    3	1	invite_status	members
    4	2	total_member_count	1
    5	2	last_activity	2013-11-03 10:35:12
    6	2	invite_status	members
    7	3	total_member_count	1
    8	3	last_activity	2013-11-03 10:37:53
    9	3	invite_status	members
    10	1	forum_id	a:1:{i:0;i:25;}
    11	2	forum_id	a:1:{i:0;i:27;}
    12	3	forum_id	a:1:{i:0;i:29;}
    

    So for group group ID 1 the bbPress forum ID 25 is stored as a:1:{i:0;i:25;} (serialized array), thus change the 25 to the correct bbPress forum ID you need.

    I’ll go write up a fix for bbPress repair tools for the next release 🙂

    Thinking about this further by updating the bbPress forum associated with the BuddyPress Group via the BuddyPress Groups edit should update the value in wp_bp_groups_groupmeta as I outlined above.

    Before you try the MySQL direct approach above could you try editing the group and seeing if the the bbPress forum ID is updated correctly please.

    Dashboard -> Groups -> Edit Group

    Then, on the far right is a dropdown to select the bbPress forum associated with the BuddyPress group, if you change this does it update forum_id in wp_bp_groups_groupmeta with the correct bbPress forum ID?


    notpoppy
    Participant

    @notpoppy

    @netweb. Thanks for the reply, glad to have helped identify a bug! I’m not sure it’s solved my problem however.

    In my database in bb_forums the forums_ids are numbered 1 through to 50. And in wp_bp_groups the ids are numbered 1 through to 50. Group id 1 corresponds to forum id 1, group id 2 corresponds to forum id 2 and so on.

    However wp_bp_groups_groupmeta contains the following:

    id 	group_id 	meta_key 	meta_value
    1 	1 	last_activity 	2014-02-27 10:56:36
    2 	1 	total_member_count 	2303
    3 	1 	forum_id 	a:1:{i:0;i:127625;}
    4 	1 	invite_status 	members
    5 	2 	last_activity 	2014-02-19 08:31:05
    6 	2 	total_member_count 	456
    7 	2 	forum_id 	a:1:{i:0;i:127626;}
    8 	2 	invite_status 	members
    9 	3 	last_activity 	2014-03-18 22:54:20
    10 	3 	total_member_count 	620
    11 	3 	forum_id 	a:1:{i:0;i:127627;}
    12 	3 	invite_status 	members
    13 	4 	last_activity 	2014-02-23 20:14:08
    14 	4 	total_member_count 	272
    15 	4 	forum_id 	a:1:{i:0;i:127628;}
    16 	4 	invite_status 	members

    So I’m not sure how those six-digit meta_values correspond to my forums.

    The group I’m having the problem with has group_id 26 and should be associated with the forum which has id 26, but instead is associated with 7. As you’d expect based on the above its value is a:1:{i:0;i:127650;}

    Is there somewhere else in the database where these longer values are connected to the correct forum_ids? As I say I’ve been looking but not found anything obvious.

    As per your original post you are using bbPress v2.5.4, the bb_forums table are part of the legacy BuddyPress Group Forums/bbPress v1.x Forums.

    bbPress 2.x no longer uses these tables, all of bbPress 2.x forums, topics and replies are in the wp_posts table as custom post types.

    If you look in the bbPress Forums panel and hover your mouse over or edit one of the forums you will see the post ID in the URL, you will find that (educated guessing here) that most of your forums have a six digit ID’s?

    Each of those ID’s should correspond to the bbPress 2.x Forum attached to each BuddyPress Group Forum as you see in your wp_groups_groupmeta table.

    So if you look in the wp_groups_groupmeta table at your group ID 26 and that 127650 value does NOT match the bbPress forum ID you expect it should match.

    Grab the correct bbPress forum ID and write down the current ID if you need to revert, bakcup your database etc etc) then update that value and I think you should be sorted.

    Also did you try updating via the ‘Group Forums’ Edit Screen UI?

    It should be correctly updating the bbPress Forum there for your BuddyPress Group, did it? did you try?


    notpoppy
    Participant

    @notpoppy

    @netweb

    if you look in the wp_groups_groupmeta table at your group ID 26 and that 127650 value does NOT match the bbPress forum ID you expect it should match.

    OK having checked the forum IDs in BBPress the value for this group should be 127650. When I check that in wp_groups_groupmeta I find the same value next to group 26, which is correct. I had a look through all the forum_ids in wp_groups_groupmeta and they all seem to be correct.

    Also did you try updating via the ‘Group Forums’ Edit Screen UI?

    Sorry I don’t know what the ‘Group Forums’ Edit Screen UI is. In the WordPress admin pages I have menus for Groups (/wp-admin/admin.php?page=bp-groups), Forums (/wp-admin/edit.php?post_type=forum), Tools>Forums (/wp-admin/tools.php?page=bbp-repair) and Settings>Forums (/wp-admin/options-general.php?page=bbpress), but I can’t see anything for ‘Group Forums’.

    However I do note that on the forums page although the ‘Edit’ button shows the correct forums_id values for each forum, the ‘View’ button shows an incorrect link for the problematic forum.

    There are two locations you can edit the bbPress Group forum associated with a BP Group:

    Frontend:
    http://example.com/groups/buddypress-public-group/admin/forum/
    Navigate to the groups ‘home page’ -> Admin -> Forum
    (Where ‘buddypress-public-group’ is the name of the group forum)

    Backend:
    http://example.com/wp-admin/admin.php?page=bp-groups&gid=1&action=edit
    Wp-Admin Dashboard -> Groups -> ‘BuddyPress Public Group’ -> Edit
    (Where ‘gid=1’ is the group forum ID)

    Each of those screens should show both a checkbox and a dropdown menu showing the available bbPress Forums to associate with that particular BuddyPress Group.

    Do both show the correct/expected bbPress forum selected?
    (If you think any of the forum names in these dropdowns is ambiguous view the HTML source of the dropdown and each forum should also have a value= form field and that will be the ID of the bbPress forum)

    However I do note that on the forums page although the ‘Edit’ button shows the correct forums_id values for each forum, the ‘View’ button shows an incorrect link for the problematic forum.

    Hmmm… To continue using my same examples I have thus far, the bbPress Forum I am using has an ID of 25 and it’s edit link is http://example.com/wp-admin/post.php?post=25&action=edit, it’s view link is http://example.com/groups/buddypress-public-group/forum/. Because BuddyPress is activated we add some redirection bits and pieces so we cannot directly modify the bbPress forum permalink whilst BuddyPress is activated.

    If you deactivate BuddyPress for a moment and check the view link of the same bbPress forum it should be similar to http://example.com/forums/forum/buddypress-forums-category/buddypress-public-group-forum/ where in my case buddypress-forums-category is the bbPress parent forum category that all by BuddyPress group forums are located under and buddypress-public-group-forum is the bbPress forum.

    So comparing my examples above do you see anything in your config that differs that matches up with your URL mismatch somewhere….

    Clear as mud all of the above 😉


    notpoppy
    Participant

    @notpoppy

    It was clear enough! 🙂

    Do both show the correct/expected bbPress forum selected?

    Yes, they do.

    comparing my examples above do you see anything in your config that differs that matches up with your URL mismatch somewhere…

    OK here’s what links I have for the forum where I have the problem with BuddyPress activated and deactivated. Note that it’s when BuddyPress is activated that the wrong group name appears on the ‘view’ link.

    BuddyPress activated

    Edit link: /wp-admin/post.php?post=127650&action=edit
    View link: /groups/incorrect-group-name/forum/

    BuddyPress deactivated

    Edit link: /wp-admin/post.php?post=127650&action=edit
    View link: /forums/forum/forums-2/f1/correct-group-name/

    And here’s the same information for a forum which is working correctly:

    BuddyPress activated

    Edit link: /wp-admin/post.php?post=127628&action=edit
    View link: /groups/name-of-another-group/forum/

    BuddyPress deactivated

    Edit link: /wp-admin/post.php?post=127628&action=edit
    View link: /forums/forum/forums-2/name-of-another-group/

    Ok, we’re closer, looks like the correct bbPress forum ID is correctly associated with the BuddyPress Group 🙂

    It looks like the slug/permalink is broken 🙁

    Before looking at a fix, a clarification if I could

    Here is my bbPress Forums Hierarchy Structure Layout

     
    BuddyPress Forums Category (Top Level Category)
    — BuddyPress Public Group Forum (Forum)
    — BuddyPress Hidden Group Forum (Forum)
    — BuddyPress Private Group Forum (Forum)

    In bbPress Settings (Settings -> bbPress) (/wp-admin/options-general.php?page=bbpress)

     
    “BuddyPress Integration” -> “Group Forums Parent” is set as “BuddyPress Forums Category”

    My bbPress settings for forum slugs are:

     
    – Forum Root Slug -> forums
    – Forum Prefix -> Check/Tick
    – Single Forum Slugs -> Forum -> forum

    So my URL’s are build with the “forum root slug” then the “forum single slug” then “BuddyPress Forums Category” and lastly the actual forum “BuddyPress Public Group Forum” which results in:

    /forums/forum/buddypress-forums-category/buddypress-public-group-forum/

    Now onto your URL’s:

    Yours with bbPress forum ID 127650

     
    /forums/forum/forums-2/f1/correct-group-name/

    Yours with bbPress forum ID 127628

     
    /forums/forum/forums-2/name-of-another-group/

    These infer the following:

     
    forums-2
    — f1
    — — correct-group-name
    — name of another group

    With your settings:

     
    “BuddyPress Integration” -> “Group Forums Parent” is set as “forums-2”
    – Forum Root Slug -> forums
    – Forum Prefix -> Check/Tick
    – Single Forum Slugs -> Forum -> forum

    As long as the quote/code formatting displays as expected is this what your bbPress forums layout hierarchy looks like?

    EDIT: Tweaked the formatting above and just trying to digest where the forums-2 comes from and why it is there, the f1 no doubt is part of the incorrect forum slug that we can get to with the fix, I’ve got to go dig through some source code of bbPress & BuddyPress to workout where things are broken and how to fix it.


    notpoppy
    Participant

    @notpoppy

    OK three of the four were right:

    – Forum Root Slug -> forums -> correct
    – Forum Prefix -> Check/Tick -> correct
    – Single Forum Slugs -> Forum -> forum -> correct

    However the correct value for BuddyPress Integration is:

    “BuddyPress Integration” -> “Group Forums Parent” is set as “F1”

    Ok, so are both the forums that you want to use for both groups you added the URL’s to above ‘sub-forums’ of the f1 forum?

    e.g.

     
    f1
    — correct-group-name
    — name of another group

    Presuming your forums are under the f1 parent in my previous post a couple of options to try:

    First potential solution:

    With your group forum that is broken create a new bbPress eg test under the f1 parent forum and then either via the front end or backend change that BuddyPress Group forum to point to the new ‘test’ forum you just created.

    What happens when you visit this group forum? Does it work as expected it should?

    Now go back and change the group back to the correct bbPress forum, does this fix it?

    Second solution if the first above does not work. Whilst BuddyPress is deactivated edit the bbPress forum permalink so that it matches the same URL structure as your BuddyPress Group that does work.

    Does this fix it?


    notpoppy
    Participant

    @notpoppy

    Ok, so are both the forums that you want to use for both groups you added the URL’s to above ‘sub-forums’ of the f1 forum?

    Actually I made things a bit confusing as the example group and forum I chose do not share the same hierarchy as the one where the problem lies.

    So I’ve followed the steps from your subsequent post using another group and forum that do have the same hierarchy.

    I created a new forum called ‘test forum 1’ and gave it the parent ‘F1’.


    notpoppy
    Participant

    @notpoppy

    (Sorry I hit reply too soon, more to come…)


    notpoppy
    Participant

    @notpoppy

    I then changed my group forum for the problematic group to ‘test forum 1′.

    I posted a thread in that forum and it seems to behave entirely correctly.

    I then switched back to the original forum and that also seems to work now! It also still works after deleting ‘test forum 1’.

    I’m not sure I understand what the problem was in the first place but I’m extremely grateful for your help fixing it.

    Excellent, I’m glad it’s fixed 🙂

    I’m not sure the exact cause of the issue either but I will dig around in our code and see what’s going on, one confirmed issue is the bbPress “Group Forums” repair tool so I’ll get that fixed and then take a closer look at group forum permalinks.

Viewing 17 replies - 1 through 17 (of 17 total)
  • The topic ‘[Resolved] BuddyPress incorrectly redirects to BBPress forum within group’ is closed to new replies.
Skip to toolbar