gistfile1.php

user_email ) ) $field_value = $current_user->user_email;

return $field_value;
}

gistfile1.php

<?php

// !!! Don't add the <?php above if you're adding this to the end of your functions.php file !!!

add_filter( 'field_editor_auto_populate_candidate_email', 'auto_populate_candidate_email_field' );

function auto_populate_candidate_email_field( $field_value ){
	// If field value is already set (means it was pulled from user meta) then return that value
	// or if user is not logged in return whatever $field_value is already set as
	if( ! empty( $field_value ) || ! is_user_logged_in() ) return $field_value;

	// Get the current user information
	$current_user = wp_get_current_user();
	// As long as user object is returned and has user_email property, set field_value
	if( is_object( $current_user ) && isset( $current_user->user_email ) ) $field_value = $current_user->user_email;

	return $field_value;
}
No comments yet.

Leave a Reply