I want to put contact form to user profile page via Contact Form 7 and Contact Form 7 Dynamic Text Extension .Form on profile page will send messages directly to user on profile page. I need to put user email to CF7 hidden field. This is only detail. Only code is important.I found a code but it's not working.
Profile Url : domain.com/member/username
I need shortcode which get user email according to username on url.
function func_print_user_email($user_email) {
global $query_string;
if($query_string != 'pagename=profile') {
$patterns = '/(\w+)=(\w+)&(\w+)=/i';
$username = preg_replace($patterns, '', $query_string);
} else {
global $current_user;
$current_user = wp_get_current_user();
$username = $current_user->user_login;
}
return trim($user_email);
return "testshortcode= { trim$user_email[testshortcode] }";
}
add_shortcode('testshortcode', 'func_print_user_email');
THANKS FOR SUPPORT