Show Email in Profile
mochkal@mochkal
17 Posts
#1 · May 26, 2022, 1:39 am
Quote from mochkal on May 26, 2022, 1:39 amHey guys,
can someone tell how i can show at the profile view the users email address with a mailto: ahref?
Maybe a Snipped?
Thanks a lot.
Regards
Hey guys,
can someone tell how i can show at the profile view the users email address with a mailto: ahref?
Maybe a Snipped?
Thanks a lot.
Regards
Uploaded files:Click for thumbs down.0Click for thumbs up.1
cauesocial has reacted to this post.
cauesocial
Jim@jim
117 Posts
#2 · May 28, 2022, 2:35 am
Quote from Jim on May 28, 2022, 2:35 am@mochkal
Try one of these. Second option is simpler but doesn’t make the email a hyperlink.
# Add user email to profile # OPTION 1 add_action( 'asgarosforum_profile_row', 'af_add_email_to_profile_view' ); function af_add_email_to_profile_view( $userData ) { $user_email = $userData->user_email; echo '<div class="profile-row">'; echo '<div>Email</div>'; echo '<div>'; echo '<a href = "mailto:' . wp_kses_post($user_email) . '">' . wp_kses_post($user_email) . '</a><br>'; echo '</div>'; echo '</div>'; } # OPTION 2, this is simpler but doesn't make the email a link add_filter( 'asgarosforum_filter_profile_row', 'af_add_email_to_profile_view', 10, 2 ); function af_add_email_to_profile_view( $profileRows, $userData ) { $user_email = $userData->user_email; $profileRows['email'] = array( 'title' => 'Email:', 'value' => trim(wpautop(esc_html($user_email))), ); return $profileRows; }
Try one of these. Second option is simpler but doesn’t make the email a hyperlink.
# Add user email to profile # OPTION 1 add_action( 'asgarosforum_profile_row', 'af_add_email_to_profile_view' ); function af_add_email_to_profile_view( $userData ) { $user_email = $userData->user_email; echo '<div class="profile-row">'; echo '<div>Email</div>'; echo '<div>'; echo '<a href = "mailto:' . wp_kses_post($user_email) . '">' . wp_kses_post($user_email) . '</a><br>'; echo '</div>'; echo '</div>'; } # OPTION 2, this is simpler but doesn't make the email a link add_filter( 'asgarosforum_filter_profile_row', 'af_add_email_to_profile_view', 10, 2 ); function af_add_email_to_profile_view( $profileRows, $userData ) { $user_email = $userData->user_email; $profileRows['email'] = array( 'title' => 'Email:', 'value' => trim(wpautop(esc_html($user_email))), ); return $profileRows; }
Click for thumbs down.0Click for thumbs up.1
cauesocial has reacted to this post.
cauesocial