Add current logged in user email into the listing email field

Share this resource

Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on facebook
Submitted by: Michael Shpigelman

I thought it might frustrate users from signing in. There might be a better way via php (backend) but exposing the email on the front end might be used for some other features.

If you want to keep updating your theme, duplicate these files into your child theme using the same folder structure (/sections/header.php and /templates/add-listing/submit-form.php).

Add the following line into line 90 on the header.php :

<a class="user-profile-name" data-email="<?php echo esc_attr( $current_user->user_email ) ?>" href="#" type="button" id="user-dropdown-menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">

Add this after line 16 in submit-form.php :

<script>
jQuery(function(){
	var $email = jQuery('#job_email');

	if($email.val() == ''){
		$email.val(jQuery('.user-profile-name').attr('data-email'));
	}
});
</script>