Opened 8 years ago
Last modified 6 weeks ago
#41757 new enhancement
Add action inside of add_new_user_to_blog() function
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | low |
Severity: | minor | Version: | 3.0 |
Component: | Users | Keywords: | has-patch has-testing-info dev-feedback |
Focuses: | multisite | Cc: |
Description
When adding a new user to a site in multisite, the full $meta
array is passed in from the relative entry in the wp_signups
database table, but it's impossible to do anything with it here because no action exists in this function.
- A similar action does already exist in
add_existing_user_to_blog()
. - We could use the
wpmu_activate_user
hook, but we'd need to reconfirm if the user was added to the site again, which is not ideal because some complex blog switching may need to occur to do so
I'll attach a patch shortly that adds an action to match add_existing_user_to_blog()
.
Attachments (2)
Change History (11)
#2
@
8 years ago
- Milestone changed from Awaiting Review to Future Release
I think a hook here makes sense.
I *could* see calling it added_new_user_to_blog
to match with the add_new_user_to_blog
action rather than the added_existing_user
action. It at least seems a little less generic then. :)
Also - the function docs need to be updated to indicate that $password
is no longer an ignored parameter, but is passed to the action.
#3
@
8 years ago
I've added a patch which includes the new hook with the proposed name by @jeremyfelt.
To note:
- Updated the docs for
$password
to reflect it's new use. - Added
$blog_id
as the last function to match the main functions order. - Hook is only run when there is no error from
! is_wp_error( $result )
.
Thoughts? :)
#4
@
8 years ago
- Keywords needs-testing added
Is anyone available to test this out? Any opinions on this at all etc?
This ticket was mentioned in Slack in #core by danieltj. View the logs.
8 years ago
This ticket was mentioned in PR #8476 on WordPress/wordpress-develop by @SirLouen.
7 weeks ago
#6
Trac ticket: [](https://core.trac.wordpress.org/ticket/41757)
Given that the original patch was posted 8 years ago some little modifications have occurred in the function hence the patch is not working anymore. Here is an updated PR with the updated patch with the same contents.
Props to /johnjamesjacoby /jeremyfelt and /danieltj
More info in the Trac report.
#7
@
7 weeks ago
- Keywords has-testing-info dev-feedback added; needs-testing removed
Combined Test Report
Description
This report validates that the patch works as expected using a test plugin for the hook.
To the original patch: https://core.trac.wordpress.org/raw-attachment/ticket/41757/ms-functions.diff
There have been minor mods in the file after 8 years, so I have submitted a Github PR with the patch. So this is the current patch tested here: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/8476.diff
Environment
- WordPress: 6.8-beta1-59933-src
- PHP: 8.2.27
- Server: nginx/1.27.4
- Database: mysqli (Server: 8.4.4 / Client: mysqlnd 8.2.27)
- Browser: Chrome 133.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.1
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Use-Case Reproduction
- First we need to set up a multisite.
- Second, we can create a second site for diversity. We are going to be working in this testing with
id = 2
- I have created an ad-hoc plugin to test and showcase a couple use-cases of this hook: https://github.com/SirLouen/testing-41757/archive/refs/tags/1.0.1.zip
- This plugin adds 3 simple use-cases
- It displays a log record with the data
- It adds some metadata based on the network blog
- It adds some extra capabilities
- We simply create a new user in the new network blog (must be
id = 2
). - We check in
wp-content
theuser-blog-additions.log
# cat user-blog-additions.log [2025-03-08 16:34:08] User ID: 3 was added to Blog ID: 2 with role: subscriber and password ODf8YH7j1sSO
- We check the database in
wp_usermeta
to check for a record withuser_id
= 3date_added_to_blog_2
and current date - Same for
wp_2_capabilities
and two roles:subscriber
(or whatever we gave on use creation) andaccess_premium_content
Actual Results
- ✅ Use-cases can be proven with this patch.
Supplemental Artifacts
All the required artifacts have been linked in the corresponding tests.
Adds
added_new_user
action (no prefix, no suffix, because multisite)