php - How to display current and old information for WordPress in Email message

I'm currently programming a service that sends out an Email, when an user updates his/her profile. This information will be displayed as a Discord Message (integration via Zapier). My question, my current setup only displays the old information, how can I get the newest & older version being sent out?. If I apply the same code at my profile page I do get the 'latest' version.
So the problem I currently have:{-code-1}
is the previous data, instead of the up to date variant. The$user_info_old / $user_info_old->discord_id
is empty, and if Iprint_r($olduserdata)
then I just get a1
back.
The how can I get the current information for$user_info->discord_id
and the previous data for$user_info->discord_id
? This is my current setup. Not the nicest, but it does the job for 90%.
function user_profile_update( $user_id, $olduserdata ) {
$site_url = get_bloginfo('wpurl');
$active_memberships = wc_memberships_get_user_memberships( $user_info, $args );
$user_info = get_userdata( $user_id );
$user_info_old = get_userdata( $olduserdata );
{-code-1} = $user_info->discord_id;
if ($active_memberships && {-code-1}) {
$namemembership = $active_memberships[0]->plan->name;
$user_regdate = date( 'm/d/Y h:s', strtotime( $user_info->user_registered ) );
$to = '[email protected]';
$subject = $user_info->discord_id;
$message = "**Name: **".$user_info->user_firstname." ".$user_info->user_lastname. "\n**Email Address: **" .$user_info->user_email. "\n**Membership: **".$namemembership."\n**Registered: **".$user_regdate." UTC\n".$user_info_old->discord_id."Please make sure to add correct permission and remove verified tag. \nDiscord ID:```".$user_info->discord_id."\n```".$user_info_old->discord_id."```";
wp_mail( $to, $subject, $message);
}
clean_user_cache( $user_info );
}
Update I've tried various caching methods, but nothing sofar. + as a bonus: the message tends to display twice. Is this function/hook being called twice normally?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function update() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.