Custom User Profile Fields & Dynamic Content

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:

  1. Create a new custom field in the user’s profile.
  2. 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.
  3. 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 you want to show dynamic content to people 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?)
  • 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:

  1. Create a form field that allows users to set the value in the frontend.
  2. Assign (or remove) a value automatically when a user visits a page
    on your site.
  3. Assign (or remove) a value based on a query-string
  4. 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. You can set the field’s type by changing the value of the “type” argument in the selection from shortcode.

Select – 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 – creates a date field that allows users to pick a date from a calendar. 

Text – 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

Deleting a value:

[ifso_delete_user_meta field='YOUR-FIELD-NAME' value='Option1']

Option 3: Assign a value based on a query parameter

Assign the value of a query parameter. Simply paste the shortcode below on the relevant page/s (the pages on which the query string will be applied)

Assigning a value:

[ifso_add_user_meta field='newfield' type='querystring' param='YOUR-PARAMETER']

If you would like to apply the code automatically to all of your pages, you can paste the PHP code below in your header.php or footer.php files.

do_shortcode("[ifso_add_user_meta field='YOUR-FIELD-NAME' type='querystring'

Setting Dynamic Content based on the user answer

  1. On your WordPress dashboard, go to “If>So → Add New Trigger”.
  2. Click on “Select a condition” and select one of the “User Meta” conditions (Text/Select Field; Date Field; Days Since/To Date).
  3. Set the name of the field. The name should be exactly the name in the shortcode you created in Step 1 of this guide.
  4. Set the value for which you would like to display the dynamic version.
  5. In the content field, set the content to be displayed when the value matches the value the user has set.
  6. In the default content field, set content to be displayed if the condition
    is not met.
  7. Press “Publish” and paste the shortcode generated by If>So on your website.

  • Was this Helpful ?
  • YesNo
Custom User Profile Fields
Requirements: If-So Pro