if(strpos($query, '%get_email%') !== false){
        $query = str_replace('%get_email%',  get_the_author_meta( 'user_email' ), $query);
    }

Okay so am trying to make a MySQL query and in the plugin I am trying to add a shortcode %get_email% but anyway its not returning any email in the actual query.

Like
select* from tablename where email="%get_email%";

Any idea on how to do that?

Here what is working for id –

    if(strpos($query, '%CURRENT_USER_ID%') !== false){
        $query = str_replace('%CURRENT_USER_ID%', get_current_user_id(), $query);
    }

4 Answers
4

I will approach like this:

global $current_user;
get_currentuserinfo();

$email = (string) $current_user->user_email;
var_dump($email);

You just called got the email from the current_user array and cast it into string 🙂 that’s it

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *