Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Add email parameter in URL when logged in WordPress



I'm looking for a solution to add a email parameter in my WP URL.

Something like:[email protected]


We can publish the User information (email) on any page with Get UserData

& linking with something like:

add_rewrite_tag( '%email%', '([^/]+)');

But I'm just guessing, any ideas?

Many thanks,

Answers (3)


timDesain Nanang answers:

jQuery Method

put this code in the <strong>functions.php</strong> under your theme folder

add_action('wp_footer', 'timdesain_var_footer');
function timdesain_var_footer(){
global $user_ID;

$user_info = get_userdata($user_ID);
$user_email = $user_info->user_email;
<script type="text/javascript">
var mail = 'email=<?php echo sanitize_email($user_email); ?>';
jQuery('a').attr('href', function() {
return this.href + '?' + mail;

add_action('init', 'timdesain_var_init');
function timdesain_var_init(){
//get the email here
$email = isset($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '';
//echo $email;

<strong>update: </strong>
This code can be used in all pages that based on wordpress.

Jonathan Surinx comments:

Waw that did the trick immediately! Amazing, many thanks :)

Last question: would I be able to use this for only one page of the webstite or complicate?


smc answers:

what you want to accomplish , can you explain please.

smc comments:

you can use following function to add param to url

Jonathan Surinx comments:

Oh right : I need this just to be able to catch this email in another program (just to avoid the user to register 2 times, once on WP and once on my own program).

Thanks for you reply, would this add_query_arg work with adding an email from a registered user?

smc comments:

you have to pass the email and the url to the function I told you .. let me know if not works for you..


Romel Apuya answers:


have you read this?
[[LINK href=""]][[/LINK]]

Jonathan Surinx comments:

Not yet thanks !

This plugin also already exist...

Will look into it.