Here is what you’d want to do:
/**
* Modify the message sent to a user after being approved.
*
* @param $message The default message.
* @param $user The user who will receive the message.
* @return string the updated message.
*/
function my_custom_message( $message, $user ) {
$message = 'Custom message here';
return $message;
}
// add a new custom approval message
add_filter( 'new_user_approve_approve_user_message', 'my_custom_message', 10, 2 );
// add a new custom denial message
// use this for a denied user
//add_filter( 'new_user_approve_deny_user_message', 'my_custom_message', 10, 2 );
What you said is to create a new custom message to the user.
What i want is to change/add more emails to receive a notifications when a new user is registated.
Sorry about that. Here is a code sample to do what you wanted.
/**
* Modify the contents of the message sent to the admin when a user signs up.
*
* @param $message The default message.
* @return string the updated message.
*/
function my_custom_message( $message ) {
$new_message = 'USERNAME (USEREMAIL) has requested a username at SITENAME' . "\n\n";
$new_message .= "SITEURL\n\n";
$new_message .= 'To approve or deny this user access to SITENAME go to' . "\n\n";
$new_message .= "ADMINURL\n\n";
return new_message;
}
// modify the message sent to the admin
add_filter( 'new_user_approve_request_approval_message_default', 'my_custom_message' );
Ok, and where do i add the admin url?
I ahve two Admins that need to receive this notifications..
This is not resolved, can you help me doing what i need?
The admin url is already in the email. But if you want to customize it, you would need to modify it using the filter as shown above.
If you want to add more admins to receive the email, you can do the following:
function email_admin( $to ) {
// add more email addresses
$to[] = 'email@example.com';
return $to;
}
add_filter( 'new_user_approve_email_admins', 'email_admins' );
If you don’t want to add any code, I have an addon plugin available for purchase with these setup as options (https://newuserapprove.com).
Uhmm, i have added your code, but isnt working
add_filter( 'new_user_approve_email_admins', 'email_admins' );
should be
add_filter( 'new_user_approve_email_admins', 'email_admin' );
function email_admin( $to ) {
// add more email addresses
$to[] = 'email@example.com';
return $to;
}
add_filter( 'new_user_approve_email_admins', 'email_admin' );