#26317 closed enhancement (duplicate)
Add filter for changing the 'New Site Created' email sent to site's admin email
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.0 |
| Component: | Networks and Sites | Keywords: | has-patch |
| Focuses: | administration, multisite | Cc: |
Description
While doing my WordPress work, I found the need of disable all the WordPress Multisite notification emails that are sent to the administrator. But one mail keep being sent: "[Sitename] New Site Created".
I decided to analyse the core's code, and found that the email was being sent on line 91, of wp-admin/network/site-new.php, and there was no filter to disable it (it was just a wp_mail call).
$content_mail = sprintf( __( 'New site created by %1$s
Address: %2$s
Name: %3$s' ), $current_user->user_login , get_site_url( $id ), wp_unslash( $title ) );
wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
Since I guess that this should be filtered, I decided to create a new filter, by replacing that lines with a single function call:
$user_name = $current_user->user_login;
$address = get_site_url( $id );
wpmu_admin_new_site_notification( $user_name, $address, $title );
The new wpmu_admin_new_site_notification that I created, is declared on wp-includes/ms-functions.php and it as simple as a function that send an email to the administrator, and that have three filters: wpmu_admin_new_site_notification that can be used to bypass the email; update_new_site_notification_email that can change the content of the emaiil; and update_new_site_notification_subject that can be used to change the subject of the email.
You can see more details of this on the .patch file I submitted, with commented code.
Attachments (2)
Change History (16)
#2
follow-up:
↓ 3
@
12 years ago
- Milestone changed from Awaiting Review to 3.9
- Version changed from 3.8 to 3.0
Thanks for the ticket and the patch, vaurdan. It is interesting that we only fire the quick email with wp_mail() to the admin right before an abstracted event for wpmu_welcome_notification().
If we pull this out into a new function, we should identify where else it could be used to notify an admin that a new site has been created. It should also likely not have the wpmu_ prefix, as that was ported over in the WPMU transition. We'd be ok to do something more like wp_new_site_admin_notification() I think.
We can probably move the get_site_url() check into the new function and pass the $id along as we do in wpmu_welcome_notification().
I think it makes sense to see how we can improve this going forward. The new site notification emails are pretty light at the moment. It looks like it has been this way since MU was ported over via [12603].
#3
in reply to:
↑ 2
@
12 years ago
Replying to jeremyfelt:
Thanks for the ticket and the patch, vaurdan. It is interesting that we only fire the quick email with
wp_mail()to the admin right before an abstracted event forwpmu_welcome_notification().
Yup, that doesn't make much sense, this was probabily old and forgotten code.
If we pull this out into a new function, we should identify where else it could be used to notify an admin that a new site has been created. It should also likely not have the
wpmu_prefix, as that was ported over in the WPMU transition. We'd be ok to do something more likewp_new_site_admin_notification()I think.
We can probably move the
get_site_url()check into the new function and pass the$idalong as we do inwpmu_welcome_notification().
I think it makes sense to see how we can improve this going forward. The new site notification emails are pretty light at the moment. It looks like it has been this way since MU was ported over via [12603].
Yes, you're right. I used the prefix wpmu_, just because all the functions there had wpmu_ as well, but makes much more sense using ´wp_´, since there is no wpmu anymore...
#7
@
12 years ago
- Keywords needs-patch added; has-patch removed
This patch should be updated / clarified a bit before going in.
From earlier:
- If we pull this out into a new function, we should identify where else it could be used to notify an admin that a new site has been created. (Otherwise the abstraction may not be necessary)
- It should also likely not have the wpmu_ prefix, as that was ported over in the WPMU transition. We'd be ok to do something more like wp_new_site_admin_notification() I think.
#8
@
12 years ago
- Milestone changed from 3.9 to Future Release
Going to push this to a future release. We should review what else can be done around this.
#9
@
12 years ago
- Keywords has-patch added; needs-patch removed
I've fixed the patch with all the suggestions that have been made.
Besides, I did a little research on the code, trying to find where wp_admin_new_site_notification function could be used, but I didn't found any place.
I still think that make a new function is the best decision, mainly because can it be easily hooked and filtered...
So, here is the new .patch, using the latest svn revision (27489).
#12
@
5 years ago
- Focuses administration added
- Milestone set to Future Release
- Summary changed from Added Filter to be possible to disable/change the 'New Site Created' email sent to Administration email address to Ad filter for changing the 'New Site Created' email sent to site's admin email
The most recent patch needs to another refresh.
#13
@
6 months ago
- Keywords needs-refresh removed
- Resolution set to worksforme
- Status changed from new to closed
This has already been sorted here #42134 plus some extra additions (like content and subject filtering).
Time to close this ticket.
#14
@
6 months ago
- Component changed from Mail to Networks and Sites
- Milestone Future Release deleted
- Resolution changed from worksforme to duplicate
- Summary changed from Ad filter for changing the 'New Site Created' email sent to site's admin email to Add filter for changing the 'New Site Created' email sent to site's admin email
Duplicate of #42134.
Patch to implement this enhancement