I need exactly the same functionality!
been trying to use “current_user->user_email” in a shortcode, but it doesnt seem to work yet.
It must be something with “CF7_get_current_user”
Any help is much appreciated 🙂
With “CF7_get_current_user” you can display the logged in username.
But “CF7_get_current_user_email” or “CF7_get_user_email” doesnt seem to work.
The other question is : how to merge the dynamic info into the email / name field of Contact Form7 ?
Did anyone have any luck with working out how to autopopulate the user email field?
I just managed to fix this
Just download User Shortcodes plugin
and then use this
Email* [dynamictext theUserEmail “currentuser_useremail”]
Excellent. Thank You gchron!! 🙂
This will add new shortcodes:
[dynamictext dynamictext “CF7_get_current_user_email”]
/* Insert information about the current user email
*/
function cf7_get_current_user_email($atts){
extract(shortcode_atts(array(
'key' => 'user_email',
), $atts));
global $current_user;
get_currentuserinfo();
$val = $current_user->$key;
return $val;
}
add_shortcode('CF7_get_current_user_email', 'cf7_get_current_user_email');
[dynamictext dynamictext “CF7_get_current_display_name”]
/* Insert information about the current user name
*/
function cf7_get_current_display_name($atts){
extract(shortcode_atts(array(
'key' => 'display_name',
), $atts));
global $current_user;
get_currentuserinfo();
$val = $current_user->$key;
return $val;
}
add_shortcode('CF7_get_current_display_name', 'cf7_get_current_display_name');
-
This reply was modified 9 years, 8 months ago by
alkovalyov.
Did anyone find the way the have a placeholder if the user isn’t logged instead and the field automatically filled if he is logged?