Page 1 of 1

Email sent on member import

PostPosted: February 2nd, 2012, 8:26 am
by epixmedia
Hi all, I'm getting ready to put a clients site live. I deleted the member data base, moved the site to their own talktalk hosting account and then re-imported the member data spreadsheet as some changes had been made.

My client is this morning reporting members saying they have received the email "your membership has been approved". I thought the import routine acted silently? I do have the function user_role_update( $user_id, $new_role ) in my functions.php but this should only be triggered when a user role is updated, the user roles where imported as s2member level 1 and not changed...

Any advice on what might have caused this would be gratefully appreciated.

Thanks,

Zoe

Re: Email sent on member import

PostPosted: February 2nd, 2012, 6:55 pm
by Raam Dev
Hi Zoe,

Can you share the entire code for the user_role_update() function that you're using?

Re: Email sent on member import

PostPosted: February 3rd, 2012, 3:45 am
by epixmedia
Hi Raam, here it is, though I did run in member data before I moved the site and no emails were triggered...

function user_role_update( $user_id, $new_role ) {
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$to = $user_info->user_email;
$subject = "Account Approval: ".$site_url."";
$message = "Hello " .$user_info->display_name . ", Your account has now been approved on ".$site_url;
wp_mail($to, $subject, $message);
}
add_action( 'set_user_role', 'user_role_update', 10, 2);

Re: Email sent on member import

PostPosted: February 3rd, 2012, 12:24 pm
by Raam Dev
Hi Zoe,

I'm guessing that the import routine triggers set_user_role and as a result, that function is being triggered.

Can you temporarily comment out the add_action line below that function when doing the import and see if that fixes it?

Re: Email sent on member import

PostPosted: February 3rd, 2012, 2:14 pm
by epixmedia
Hi Raam, will have to wait to try that on another site as the member data is all imported now.

I didn't suspect that function because its always been in the functions.php and I've run the import procedure before without it triggering emails!

I'll just keep my eye on it on future projects and report back if it happens again :)

Thanks!

Zoe