Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm writing a simple API endpoint which allows a 3rd party site to create new users. Everything works but the 3rd party site is set up to only wait 5 seconds, and for some reason, when I create a new user and then call wp_new_user_notification() it takes around 5 full seconds to send the response. Half the time the 3rd party site times out waiting.

When I comment out the new user notification, it's almost instant. So I know the slowness is coming from that line of code. I have two plugins that deal with new user emails, but I experimented by deactivating both of them and it's still slow. Any ideas why this is happening? I looked at the source code for the function, and it doesn't look like it should take that long.

Thanks for any advice you can give me!

UPDATE:

I did a test using wp_mail()...

$time3 = time();
wp_mail( "me@gmail.com", "SUBJECT", "MESSAGE" );
$time4 = time();

echo "wp_mail(): ". ($time4 - $time3);

And I get back wp_mail(): 1

I think this suggests that the delay is inside wp_new_user_notification() but outsidewp_mail()`.

UPDATE2: I'm not receiving any email from wp_mail() when I use it in my plugin. Perhaps there's some dependency that I'm missing.

share|improve this question
Is it slow if you isolate the function and run it alone? Are other functions, sending emails out, slow? – Rarst Sep 28 '12 at 17:43
Good idea. Can you suggest other functions that send emails? I'm not very familiar with this part of the core. – Emerson Sep 28 '12 at 17:58
Well, essentially any of them will be using wp_mail() so try testing it. – Rarst Sep 28 '12 at 18:02
Updated the question with my test result. When I call wp_new_user_notification(2) it's 2 seconds, but the email doesn't arrive, so something is fishy. – Emerson Sep 28 '12 at 18:34
I'm testing with wp_mail() in a template file and wp_mail() in my plugin and the first works fine, but the second doesn't. Do you have any idea why that would be? – Emerson Sep 28 '12 at 19:25
show 2 more comments

closed as too localized by Rarst Sep 28 '12 at 20:41

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.