I'm trying to get the user email for a user by using their username. The information should be for the user whose profile is being viewed, not for the user that's currently logged in.
I tried the code below, but it's not working for me (it's giving me an undefined function error):
$userdata = get_data_by( 'user_nicename' , $rusername );
if ( !$userdata )
$rusermail = $userdata->user_email;
Is there any way to get the user's email address from the database with the username that doesn't rely on a string?
Thanks!