Function and usage of admin_created_user_email() in wordpress


Answers ( 1 )


    The admin_created_user_email() function in WordPress is designed to modify the content of the email sent to the admin when a new user is created in the WordPress system. This function is typically used within the context of a WordPress plugin or theme to customize the notification emails that admins receive.

    Function Signature:

    admin_created_user_email( string $text ): string


    • $text (string, required): This parameter represents the original content of the email that is sent to the admin when a new user is created. It is the text that you intend to modify or augment.


    • The function returns a string. This string is the modified or new content of the email that will be sent to the admin.


    To use this function, you generally hook into it using the add_filter() function provided by WordPress. Here's an example of how it might be used:

    function customize_admin_email_content( $original_email_text ) {
        // Modify the original email text in some way
        $custom_text = "Custom message: \n\n" . $original_email_text;
        // Return the new email content
        return $custom_text;
    // Hook the above function to 'admin_created_user_email' filter
    add_filter( 'admin_created_user_email', 'customize_admin_email_content' );

    In this example, a custom function customize_admin_email_content is defined. This function takes the original email content as an argument, modifies it by appending a custom message, and then returns the modified text. This function is then hooked to the admin_created_user_email filter, so that every time an admin email is generated, this custom function is used to modify the content of that email.

    Remember that this function, like many WordPress functions, is part of a plugin/theme development process and requires understanding of WordPress hooks and filters system.

Leave an answer