The Custom User Profile Fields extension is a complete solution for collecting data from logged-in users and displaying dynamic content based on the data.
The extension allows you to:
- Create a new custom field in the user’s profile.
- Assign a value to the custom field by either allowing the user to set the value or by automatically assigning it when the user visits a page on your site.
- Display dynamic content based on the value of the custom field.
What is the Custom User Profile Fields Extension used for?
Sometimes, the best way to show users the most relevant content is simply to ask them what content they are interested in seeing.
The Custom User Profile Fields extension is useful when you want to display dynamic content to logged-in users. It will allow you to collect any information from and about your users, save it in their user profile, and display dynamic content based on the collected data.
If your users do not logged-in to your site, please check out our User Self-Selection extension.
Which types of fields can you set to collect data from users?
You can set three types of fields:
- A selection within a list of options
- A date (did somebody say birthday date?)
- Free text
How to set up dynamic content based on a custom user profile field
A custom profile field will automatically be created in the backend when a value is assigned to the user’s profile (you do not need to actively create the custom field on your WordPress dashboard).
Assigning a value can be done either by you or by your user. There are three options to assign a value:
- Create a form field that allows users to set the value in the frontend.
- Assign (or remove) a value automatically when a user visits a page on your site.
- Assign a value through the user profile page (on your dashboard).
Option 1: Allow users to choose the value of the custom field in the frontend
Creating a form to collect data from the user is done using the simple shortcode below:
[ifso_user_meta_form field='NAME-YOU-CHOOSE' type='select' options='Option1, Option2' default-option='Unset' submit='Send']
A real-life example:
The following shortcode will create a gender selection field. The user will be able to choose between “Male”, “Female”, and “Other”:
[ifso_user_meta_form field='gender’' type='select' options='Male, Female' default-option='Unset' submit='Send']
Try it! Paste the shortcode on a page on your website exactly as it is, visit the page, and select one of the options. Then, visit your user profile page and see the new custom field and the value you selected.
Types of form fields
The extension allows you to create three types of fields:
Select field – let the user select an option from a closed list. If you are using this option your shortcode should include the “options” and the “default-option” parameters.
Date field – creates a date field that allows users to pick a date from a calendar.
Text field – creates a free text field that allows the user to type any value.
Additional form fields arguments
Submit – add and edit the value of the submit parameter to control the text on the form button
Option 2: Assign or remove a value from the custom field when a user visits a page on your site
You can choose to assign or delete a value when a user visits a page on your site. In order to do this, simply paste one of the following shortcodes on the relevant page:
Assigning a value:
[ifso_add_user_meta field='YOUR-FIELD-NAME' value='Option1']
The shortcode above creates the custom field “YOUR-FIELD-NAME” in the user profile and assigns the value “Option1”. A real life example may be [ifso_add_user_meta field=’gender’ value=’Male,Female’]
Deleting a value:
[ifso_delete_user_meta field='YOUR-FIELD-NAME' value='Option1']
Setting Dynamic Content based on the user answer
- On your WordPress dashboard, go to “If>So → Add New Trigger”.
- Click on “Select a condition” and select one of the “User Meta” conditions (Text/Select Field; Date Field; Days Since/To Date).
- Set the name of the field. The name should be exactly the name in the shortcode you created in Step 1 of this guide.
- Set the value for which you would like to display the dynamic version.
- In the content field, set the content to be displayed when the value matches the value the user has set.
- In the default content field, set content to be displayed if the condition is not met.
- Press “Publish” and paste the shortcode generated by If>So on your website.