This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
new_network_admin_email_content filter
So, you’re diving into WordPress hooks, huh? That’s awesome! Hooks are like the secret sauce that lets you tweak WordPress without touching the core files. Today, we’re talking about the new_network_admin_email_content filter. It’s a handy one that lets you customize the email content sent to the network admin when their email address is changed.
To use the new_network_admin_email_content filter, first, you gotta register it using add_filter
. Just drop this code into the functions.php of your active theme or, even better, a custom WordPress Plugin. At WePlugins, we always recommend the plugin approach. It keeps your tweaks safe during theme updates.
If you ever need to remove a filter, just use remove_filter
to yank out the new_network_admin_email_content filter.
Parameters
Below are the 2 parameters you need to use this hook:
- $email_text: (string) Text in the email.
- $new_admin_email: (array) Data relating to the new network admin email address.
- ‘hash’ (string) The secure hash used in the confirmation link URL.
- ‘newemail’ (string) The proposed new network admin email address.
Live Example 1: Basic Usage
Here’s a basic example of how you can use this hook:
function weplugins_modify_new_network_admin_email_content_defaults($email_text, $new_admin_email) { // Update the $email_text variable according to your website requirements and return this variable. // You can modify the $email_text variable conditionally too if you want. return $email_text; } // add the filter add_filter( "new_network_admin_email_content", "weplugins_modify_new_network_admin_email_content_defaults", 10, 2 );
Live Example 2: Conditional Text Change
Modify the email content based on specific conditions:
function weplugins_custom_email_content($email_text, $new_admin_email) { if ($new_admin_email['newemail'] == 'admin@example.com') { $email_text .= ' - Special instructions for the new admin!'; } return $email_text; } add_filter( "new_network_admin_email_content", "weplugins_custom_email_content", 10, 2 );
Live Example 3: Removing the Hook
To remove a hook callback, use the example below:
remove_filter( "new_network_admin_email_content", "weplugins_modify_new_network_admin_email_content_defaults", 10, 2 );
Make sure to provide the same callback function name, priority, and number of arguments when removing the hook callback.
Contact Us
If you need any customization or have questions about using this hook, feel free to contact us. We’re always here to help!
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.