Quick tutorial for displaying the user’s email address as link in post content.

For example, let’s say that you collect the user’s email address using the following form:

[usp_name]
[usp_title]
[usp_email]
[usp_content]

For each post submitted using that form, the user’s email address will be attached as a custom field. As with any custom field, you can display the user’s email address in the post content using a shortcode or template tag.

Display user email via shortcode

To display the user’s email in any Post or Page, use the following shortcode:

[usp_meta meta="usp-email"]

Display user email via template tag

Likewise, to display the user’s email anywhere in the WordPress Loop, use the following template tag:

<?php echo usp_get_meta(false, 'usp-email'); ?>

Make ’em links

For maximum flexibility, the shortcode and template tag display only the contents of the custom field. This means that when displayed on the page, the email address will appear as plain text. To make it a clickable link, just do either of the following:

<a href="mailto:[usp_meta meta="usp-email"]">[usp_meta meta="usp-email"]</a>

Or likewise with template tag:

<a href="mailto:[usp_meta meta="usp-email"]"><?php echo usp_get_meta(false, 'usp-email'); ?></a>

Notes

This same technique can be used to display any custom field. Just replace “usp-email” with the name of your custom field. See these fine posts for more information: