Skip to:
Content

BuddyPress.org

Opened 13 years ago

Closed 13 years ago

#3916 closed defect (bug) (fixed)

Blog not properly added when accepting invitation sent via Dashboard

Reported by: boonebgorges's profile boonebgorges Owned by:
Milestone: 1.6 Priority: normal
Severity: normal Version: 1.5.2
Component: Blogs Keywords:
Cc:

Description

When you invite an existing user to a blog via Dashboard > Users > Add New, a confirmation email is sent that goes to a URL that looks like:
http://example.com/newbloguser/abc123/

When that happens, the function maybe_add_existing_user_to_blog() (ms-functions.php) fires, and then does add_existing_user_to_blog(), etc. During that process, the BP blog-related functions are loaded (in particular, bp_blogs_add_user_to_blog(), which is hooked to add_user_to_blog).

However, these function don't work in this case. It's because WP's maybe_add_existing_user_to_blog is hooked to init at priority 10, as is the BP setup routine. In this case, it appears that WP is winning the tie, with the result that when the BP function fire, the Blogs component has not been set up. (The main symptom is that, with WP_DEBUG enabled, you see that the blogs database tables, $bp->blogs->table_name etc, are not defined.) As a result, the add-user-to-blog BP functions fail to run correctly.

Not sure how to fix this. On a single site, it's easy: in an mu-plugin (which is loaded nice and early), do something like this:

remove_action( 'init', 'maybe_add_existing_user_to_blog' );
add_action( 'init', 'maybe_add_existing_user_to_blog', 90 );

That ensures that BP will be loaded by the time WP attempts to run add_user_to_blog(). We could do something similar in the global scope of the BP Blogs component (but not in the component loader, which is initiated at bp_init->init:10), but it seems hackish, and may interfere with other plugins. Other ideas?

Attachments (1)

3916.01.patch (1.0 KB) - added by boonebgorges 13 years ago.

Download all attachments as: .zip

Change History (7)

#1 @boonebgorges
13 years ago

  • Keywords 2nd-opinion has-patch added

Bump. 3916.01.patch works, but is ugly, and risks breaking any other plugin that attempts to unhook maybe_add_existing_user_to_blog() (though that would be an *extreme* edge case). I think that 3916.01.patch is better than nothing, as this is a pesky bug, and we have no place in the BP interface where admins can reindex user blogs to correct the error when it arises. Willing to entertain alternative suggestions before I put this in.

#2 @johnjamesjacoby
13 years ago

Is the problem that bp_init is hooked into init at 10? Is there a blogs function that needs to be hooked in earlier? Or is it the entire component loading too late? Maybe a core patch is in order instead?

#3 @boonebgorges
13 years ago

Maybe a core patch is in order instead?

This would be easiest, at least for us. Maybe they could hook to wp_loaded instead. I don't see a solid reason for asking WP to change, aside from the fact that BP needs it, though.

#4 @boonebgorges
13 years ago

(In [5775]) Unhooks and rehooks WP's maybe_add_existing_user_to_blog() so that we can initialize the BP Blogs component before WP attemps to add users in this way. See #3916.

#5 @djpaul
13 years ago

(In [5777]) Add multisite check to avoid php warning. See #3916.

#6 @boonebgorges
13 years ago

  • Keywords 2nd-opinion has-patch removed
  • Resolution set to fixed
  • Status changed from new to closed

Marking resolved, as it's working now, though the solution is not optimally elegant.

Note: See TracTickets for help on using tickets.