Skip to:
Content

Opened 4 years ago

Closed 2 years ago

#2350 closed defect (bug) (fixed)

Add user to blog in console

Reported by: motomac Owned by:
Milestone: 1.6 Priority: normal
Severity: minor Version:
Component: Core Keywords: needs-patch
Cc:

Description

WPMU+BP
If I want to add my friend to my blog adding a new unregistered user in console (/wp-admin/user-new.php), my friend recieved an invitation mail with a link like: http://abc.com/wp-activate.php?key=8d4acfd2530dcae2&e=1

It doesn't work.

Attachments (3)

patch-2350.patch (1000 bytes) - added by DJPaul 4 years ago.
patch-2350-2.patch (1.1 KB) - added by DJPaul 4 years ago.
patch-2350-2.2.patch (1.1 KB) - added by DJPaul 4 years ago.

Download all attachments as: .zip

Change History (26)

comment:1 boonebgorges4 years ago

  • Keywords reporter-feedback added; invite registration wpmu removed

The URL you give is a WPMU activation URL. BP activation URLs are of the form abc.com/activate?key=xyz.

A test on WPMU 2.9.2 + BP 1.2.3 shows that BP is correctly filtering the WPMU address and changing it into the BP address. Is this the configuration where you're experiencing the problem? Are you inviting users to the main blog (where BP is running) or to a secondary blog?

comment:2 motomac4 years ago

If I add user to main blog, my friend have recieved a right link:

http://abc.com/activate?key=217e4806f7f43bb5&e=1

and registration works fine (but without filling bp registration form).

But if I add user to secondary blog, a have an error link in activaction mail

http://abc.com/wp-activate.php?key=8d4acfd2530dcae2&e=1 

comment:3 DJPaul4 years ago

Is BuddyPress activated site-wide or just on the main blog?

comment:4 DJPaul4 years ago

duplicate of #1610, it seems

comment:5 DJPaul4 years ago

Confirmed on non-main blog 'add user' via wp-admin on BP 1.2 branch and WP 3.0 rev 14326. Working on a patch...

DJPaul4 years ago

comment:6 DJPaul4 years ago

  • Keywords has-patch tested added; reporter-feedback removed

On a WPMU BP site, you want user registration and user activation to happen on the BP_ROOT_BLOG. The BP functions which send the user account activation email do not handle this situation correctly when an Admin adds a user via the wp-admin backend on a blog which isn't the BP_ROOT_BLOG.

The locate_template calls look for activate.php or /registration/activate.php on this non-BP_ROOT_BLOG, and unless this blog contains that file (i.e. most probably running a BP theme), it falls back to the standard wp-active.php. Attached is a patch which duplicates some of the locate_template logic because constants can't be redefined (obviously).

comment:7 apeatling4 years ago

Can we do this without switch_to_blog()?

comment:8 DJPaul4 years ago

get_stylesheet_directory() -> get_stylesheet() -> apply_filters('stylesheet', get_option('stylesheet'))

I'll have a look after work but I think the get_blog_prefix() call within switch_to_blog() is where the magic happens.

DJPaul4 years ago

DJPaul4 years ago

comment:9 DJPaul4 years ago

Take a look at patch-2350-2.2.patch (the other one had debug code).

comment:10 apeatling4 years ago

Just tested the original problem and it works ok for me. The URL will only be /activate/ if a BuddyPress theme is activated and it has a custom activation template. It should just be the standard wp-activate.php link otherwise.

comment:11 apeatling4 years ago

This was on 1.2.4-pre and WPMU 2.9.2. Testing now on 3.0 latest.

comment:12 DJPaul4 years ago

As per previous comment:
On a WPMU BP site, you want user registration and user activation to happen on the BP_ROOT_BLOG. The BP functions which send the user account activation email do not handle this situation correctly when an Admin adds a user via the wp-admin backend on a blog which isn't the BP_ROOT_BLOG.... which doesn't run a BP-specific theme (and why should it? That's the whole point of multisites. Different blogs for different users).

I view this is as a valid use case.

comment:13 follow-up: apeatling4 years ago

Why should all registrations be handled on the root blog? That seems like a bad idea and is fundimentally messing with the way WPMU works. If a user has a blog and settings allow, they should be able to add users via their blog and activate them via their blog.

comment:14 apeatling4 years ago

fundamentally. ;)

comment:15 apeatling4 years ago

  • Milestone changed from 1.2.4 to 1.3
  • Priority changed from major to normal

comment:16 paulhastings04 years ago

  • Summary changed from Add user to blog in console to [patch] Add user to blog in console

comment:17 in reply to: ↑ 13 andrea_r3 years ago

Replying to apeatling:

Why should all registrations be handled on the root blog? That seems like a bad idea and is fundimentally messing with the way WPMU works.

I hate to disagree, but adding new users to the network always has to happen on the main blog. And it always did. This was how WPMU works, and how multisite works. Users gets added to the network via the main blog.

If a user has a blog and settings allow, they should be able to add users via their blog and activate them via their blog.

Once a user is a part of the network and has activated their account, users can add other users to their blog if this is enabled. If they are not part of the network, they will still get a link to the main blog.

Always did, always will. Think of how wordpress.com works. ;)

comment:18 DJPaul3 years ago

  • Keywords needs-patch added; has-patch tested removed
  • Milestone changed from 1.3 to 1.4
  • Summary changed from [patch] Add user to blog in console to Add user to blog in console

Punting this to 1.4 unless someone contributes an updated patch :) I think patch-2350-2.2.patch was in the right direction, but it will require re-testing to validate.

comment:19 boonebgorges3 years ago

  • Keywords close added
  • Severity set to normal

I'm a bit confused about the purpose of this ticket. If it's to change the way that WPMS registration works, then it's either plugin territory, or it should be taken upstream to WordPress. If it's to provide fallback support when a theme does not have the proper registration templates, then we probably should be having a broader discussion about whether BP should be doing this for *all* templates, not just those involved in registration. DJPaul's patch (if I'm understanding it correctly) kinda skirts the issue; it makes it appear like you can register on a secondary blog, but your registration emails etc will still come from the main WP site.

BTW, does anyone know what happens with respect to registration emails when BP_ROOT_BLOG != 1? Too lazy to test :)

comment:20 DJPaul3 years ago

The issue was that, in multisite, adding a user via wp-admin to the non-root-blog generated an invalid user activation URL in the email. It points to that site's wp-activate.php instead of BP's root blog's /activate= handler.

All this needs testing and reconfirming as this ticket is pre-WP 3.0.

I'm still of the opinion that user activation link should go to the BP root blog, unless the BP multiblog setting is enabled.

comment:21 boonebgorges3 years ago

  • Keywords close removed
  • Severity changed from normal to minor

I'm still of the opinion that user activation link should go to the BP root blog, unless the BP multiblog setting is enabled.

Agreed.

adding a user via wp-admin

OK, I understand it a bit better with the addition of this piece of info (I lost that point above). Probably just a matter of filtering the email content.

comment:22 DJPaul3 years ago

See also #3467

comment:23 boonebgorges2 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5366]) Deprecates bp_has_custom_activation_page() in favor of checking bp_pages for an activation page. Retools bp_get_activation_page() so that it returns the proper network registration page when adding users from a non-root Dashboard. Fixes #2350

Note: See TracTickets for help on using tickets.