How to customize the approval message to the admin?
-
I am using the plugin New User Approve to help moderate the registration of new users to our multi-user site. Right now the registration form is the default WP one with only a Username and Email field. I would like to require the new user to input a valid First and Last Name as well as a Username and Email address. Then I would like the notification email that New User Approve sends to the admin about the new registration to include the user’s First and Last Name along with the given message. This is to help identify the people signing up as usernames and emails cannot be cross-referenced with people we want accessing the site.
There are filters available in the New User Approve plugin that are supposed to allow the modification of the email message sent to the admin (as well as those sent to the new user). However, I have not been able to get these to work successfully. An example being that when I try to override the message it sends a message with all the ‘tags’ intact, rather than swapping them for the actual data. This is the code I have tried:
/* Customize the New User Approve email messages. */ add_action( 'nua_email_tags', 'mytheme2014_extras_nua_add_email_tags'); function mytheme2014_extras_nua_add_email_tags () { if (! nua_email_tag_exists( 'first_last_name' )) { nua_add_email_tag( 'first_last_name', __( 'The users first and last name.', 'mytheme2014' ), 'mytheme2014_extras_nua_email_tag_user_first_last_name' ); } } function mytheme2014_extras_nua_email_tag_user_first_last_name( $attributes ) { return '' . $attributes['first_name'] . ' ' . $attributes['last_name']; } add_filter( 'new_user_approve_request_approval_message', 'mytheme2014_extras_nua_approval_notification_message', 10, 2 ); function mytheme2014_extras_nua_approval_notification_message($message, $user) { $message = __( '{first_last_name} — {username} — ({user_email}) has requested a username at {sitename}', 'new-user-approve' ) . "\n\n"; $message .= "{site_url}\n\n"; $message .= __( 'To approve or deny this user access to {sitename} go to', 'new-user-approve' ) . "\n\n"; $message .= "{admin_approve_url}\n\n"; return $message; }
- The topic ‘How to customize the approval message to the admin?’ is closed to new replies.