The field shortcode can be used to display any of the registration fields for a logged in user. The field parameter corresponds to that field’s option name (found in the WP-Members Fields option tab; this is also the usermeta).
The field shortcode can also be used to display data about other users. This can be passed in an “id” field. The id must be either the numeric user ID of a specific user or “get” to indicate that the user ID will be passed through a querystring as “uid” (i.e. http://yoursite/your-page/?uid=123)
You can specify a field’s meta key as a shortcode attribute or you can use the attribute field=”meta_key” (where “meta_key” is the meta key for the desired field).
Usage examples:
Display the user’s username:
[wpmem_field user_login]
[wpmem_field field="user_login"]
Display the user’s first name last name:
[wpmem_field first_name] [wpmem_field last_name]
[wpmem_field field="first_name"] [wpmem_field field="last_name"]
Display email for a specific user (ID=123):
[wpmem_field user_email id="123"]
[wpmem_field field="user_email" id="123"]
Display first name/last name for an ID passed through a querystring (uid):
[wpmem_field first_name id="get"] [wpmem_field last_name id="get"]
[wpmem_field field="first_name" id="get"] [wpmem_field field="last_name" id="get"]
Additional Attributes
There are some additional attributes that can be used, primarily for specific field types.
Select (dropdown), Multiple Select, Multiple Checkbox, and Radio Fields:
These fields generally have a different saved (stored) value than what is displayed to the user (such as the case of a dropdown select field). The shortcode default is to display the “display” value of the field rather than the saved value. However, in cases where the saved value is needed, you can add the attribute display=raw to the shortcode. The following example would display the raw/saved value for the field my_dropdown:
[wpmem_field my_dropdown display=raw]
Textarea Fields:
The textarea field type also accepts the display=raw attribute as outlined above. In the case of a textarea field, this allows the field’s data to be displayed without converting line breaks to the HTML <br> tag.
Image and File Fields:
File field types display a link to the file. Image field types display the image. If this raw ID value is desired, then the attribute display=raw can be used.
[wpmem_field my_file display=raw] would display the post ID for the file.
A “file” field type will display a link to the file, using the title parameter from the post.
An “image” field type will display a thumbnail of the image. This can be changed using the “size” attribute. The value can be the following:
- thumbnail
- medium
- large
- full
- width,height
Examples
[wpmem_field my_image size=medium] would display the medium size of the image where “my_image” is the meta key (option name) of the field.
[wpmem_field my_image size="100,200"] would display the image my_image at a size of 100px wide by 200px high.
Date Fields:
The HTML “date” field type will automatically format its output based on the localized date format setting you have in your WordPress General Settings.
If you want to display this field in another format, you can apply the attribute “format” based on PHP date format parameters.
Clickable Links:
Any field that holds content that may be displayed as a link (either a URL or an email address) can be made clickable by applying the “clickable” attribute set to true. This can be individual field data such as user_email (making the link a mailto: link) or user_url (making the URL clickable), or it can be a text or textarea field type that contains a URL or email address in which case that piece of the content would be made into a clickable link.
Example:
[wpmem_field user_email clickable=true]
A (not fully exhaustive) List of Parameters from the default install:
WP Default Fields:
- ID
- user_login
- user_email
- user_nicename
- user_registered
- user_url
- first_name
- last_name
- aim
- yim
- jabber
- description
WP-Members Default Fields:
In addition to the above list:
- addr1
- addr2
- city
- thestate
- zip
- country
- phone1
- tos
Additional Fields:
Any fields that you might add to the plugin’s registration process can be displayed in this same way. The value you give to the Option Name is the parameter that you would use. [See Choosing Fields for how to set up custom fields in the plugin registration]