Duplicate Registration Pending Emails Sent
-
Hi Callum,
You may remember a while ago I asked how to set users to pending when they edited an existing account so admin could review the edits. I also wanted to send admin an email to notify admin when a user edits an existing account.
I’m not very good at PHP at all, but in the end I figured out a code fix on my own using the plug-in code for direction – included below.
However, we have noticed an issue. New new users are receiving duplicate registration pending emails.
It is definitely the code I added that is causing this issue; I have removed it and only one pending email is sent.
I cannot understand this because I thought all my code does is set a ‘user status’ to pending when the ‘um_user_edit_profile’ function is triggered.
Can you possibly please let me know why this is triggering a duplicate email? And, if you have a little time could you please show me how to make my code set users to pending after editing their existing profile without sending a duplicate email at registration?
Many thanks,
Dan.
// Set profile to under review after edits add_action('um_user_edit_profile', 'um_post_edit_pending_hook', 10, 2); function um_post_edit_pending_hook($user_id, $args){ if ( is_super_admin() ) { return false; } else { global $ultimatemember; $ultimatemember->user->pending(); } } // Email admin after edits add_action( 'um_user_edit_profile','notify_admin_on_update'); function notify_admin_on_update(){ global $current_user; get_currentuserinfo(); if (!current_user_can( 'administrator' )){// avoid sending emails when admin is updating user profiles $to = 'admin@enterprise-team.co.uk'; $subject = 'user updated profile'; $message = "the user : " .$current_user->business_name . " has updated his profile with:\n"; foreach($_POST as $key => $value){ $message .= $key . ": ". $value ."\n"; } wp_mail( $to, $subject, $message); } }
The topic ‘Duplicate Registration Pending Emails Sent’ is closed to new replies.