Hi,
This is a little bit complicated so please bear with me.
Basically I've been trying to sort out my confirmation emails that get sent when a user registers. The email routing included in Gravity Forms is good but it isn't customisable enough for me needs so I've been trying to write my own. I think the code is simple enough but I've run into a bit of a confusing wall.
My first plan was to write a custom plugin to override the wp_new_user_notification function, as per the Wordpress documentation. Here are my efforts:
It worked fine and routed the correct emails to the correct places. The problem I encountered here was that I couldn't access extra user metadata captured at the same time as registration, so after feeling like it was a dead end I used the plugin to simply disable the function in favour of using the gform_after_submission hook to send the emails on for completion, this way all metadata is already stored.
I've been working at it and it's working fine for one type of user registration, seen here:
However, when I've been trying to mimic the functionality with the other user type I keep hitting errors. The main issue is that
$user = new WP_User($entry[24]); //Take the $user_id and use the WP_User function to access all information about the newly registered user
is returning false. So I've tried using
$user = get_user_by('login', $entry[15]); //Find the user data
but this just returns NULL. How does this make any sense when it works perfectly in the other example? I've tweeked it around a lot, here's where I am right now:
Can anyone help me with this, I've been going round in circles for hours now and I can't make any sense of it. I've tried putting in a usleep() to make sure it isn't just taking a little too long but to no avail.
A live test is online but please PM me for access as I don't want it posted publicly.
Many thanks.