3

I have created a WordPress shortcode in functions.php that looks like this:

function user_email() {
}
add_shortcode( 'user_email', 'user_email' );

This captures the logged-in WordPress user's email address. I want to pass that email address in a query string, so the end result would look like this:

https://ofcoursebooks.com/bmf?email=ashli@example.com

To do that, I was hoping to pass the email address via the short code:

https://ofcoursebooks.com/bmf?email=[user_email]

That doesn't seem to be working though... it just passes the actual [user_email] text.

What did I miss?

Tomasz
  • 4,847
  • 2
  • 32
  • 41
Ash
  • 345
  • 1
  • 5
  • 16
  • 1
    Why do you need a shortcode to get the user's email address? Can you not just use something like `$user = wp_get_current_user(); $user->user_email` to get their email address which can then be echoed where necessary e.g. in the query string of your URL. – Michael Apr 22 '16 at 22:02

0 Answers0