Profile

Profile

{{ profile }}

Properties of {{ profile }} objects
Name Type Description
object_type String Will always be datastore_item
is_valid Boolean True if this references a published profile
guid String The unique identifier for this profile
value String Contains the same value as guid
id String The identifier for the profile. May or may not be the same as email, depending on the site settings
email String Email address for this profile
force_password_reset Boolean If true, the user must reset their password at next login
is_active Boolean If true, the profile is active and can be used. If false, the profile must be activated before it may be used
date_activated time The date that this profile was activated
date_activation_code_expires time The date when the activation code will expire and no longer be valid
date_first_activated time The date of the first successful activation for this profile
is_locked Boolean If true, this profile is temporarily locked and may not be used to sign in until it is unlocked
date_locked_through time If this profile is locked, this will be set to the date that the profile will be automatically unlocked
date_last_logged_in time The date that this profile was last used to sign in to the website
is_blocked Boolean If true, this profile has been permanently blocked and may not be used to sign in
date_blocked time If this profile is blocked, this will be set to the date when the profile was blocked
attributes dictionary The custom attributes for this profile. Attributes may either be manually set in the Marketpath CMS UI or programmatically set from template markup
logged_in Boolean True if this profile is presently logged in on the current request
can_login Boolean True if the profile exists, is active, and is not blocked or locked
settings object An object containing all of the custom profile settings for this profile
field_id String The identifier for this field
label String The label for this field
output String The default output that the profile produces when output directly to the template. Currently simply outputs the email, but the default output may change at any time. Template developers should avoid using this and should handle the output of profiles themselves

Related

Root Scope Reserved Variables

Every page on the site is created by processing templates using specific pre-defined inputs. These reserved variables are present on the root scope of every pageload.

object

May be any object, including simple, complex and list objects. In some cases may even include symbols and null.

{{ dictionary }}

Object containing a list of key-value pairs where the keys are unique.

{{ code }}

{{ date }}

A field containing a user-selected date

{{ request }}

The request object is available on every page, and contains information regarding the HTTP request that may be useful for serving and rendering the page.

string

Can be any text, from the empty string ("") to the full HTML output of the template. When used alone in a conditional, all strings evaluates as true - even if they are empty or a value such as "0" or "false".

{% profile %}

{{ template }}

{% profiles %}

{{ auth }}

Stores information about the current state of profile authorization, which is the result of calls to the {% auth %} methods.

{{ time }}

Represents a specific instant in a specific timezone.

{{ site }}

The site object is available on every page, and contains information about the current site. This information is the same on every page for the site.

boolean

True or False

{{ profiles }}

Contains multiple profiles.

{{ profiles }}

Contains multiple profiles.

Properties of {{ profiles }} objects
Name Type Description
object_type String Will always be datastore_item
is_valid Boolean True if this contains at least one published profile
output String The default output that the profiles will produce when it is output directly to the template - using the "output_in_list" property of each profile in the items list
prepended list List containing any prepended profiles.
fetched list List containing all of the profiles that were fetched from the database (as opposed to prepended or appended).
appended list List containing any appended profiles.
appended_unique list List containing any appended profiles excluding any profiles that are in either the list of prepended or fetched profiles.
items list List containing all of the combined profiles from the prepended, fetched, and appended lists. If unique is true, this list will not contain any duplicates. If max_size is set, this list will not contain more than the number of profiles specified.
size Integer The total number of profiles in the items list, including prepended, fetched, and appended lists, and respecting the unique and max_size properties.
max_size Integer If set, this is the maximum number of items that will be returned in the items list and the maximum number of items that will be included when this profiles object is enumerated as a list. When not set, this value will be 0.
unique Boolean When true, the items list will not contain any duplicates. Only the first instance of each profile will be included.
limit Integer The maximum number of items that were allowed to be in the list of fetched profiles. May be 0 in some cases (such as when when there are no fetched profiles.
start Integer The 1-based index of the first item in the list of fetched profiles.
page Integer The 1-based index of the paginated results returned in the list of fetched profiles, which is calculated from the start and limit parameters. Useful for paginated results.
total_count Integer The 1-based index of the first item in the list of fetched profiles
total_pages Integer If any items were fetched from the database, total_pages will contain the number of paginated result pages in the database for the provided arguments. This may also be calculated using the total_count and limit properties.

Related

{% profile %}

{{ profile }}

{% profiles %}

{% profile %}

{% profile output_to_template? [[var, set, or assign]? variable]? output_to_template? = value %}

{% profile
output_to_template
 
If included the profile will be output directly to the template.
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this profile is stored on. "var" is the default behavior.
variable_name
 
Specify a variable name in order to save this profile to a variable. If not specified, it will be output to the template instead.
output_to_template
 
If included the profile will be output directly to the template.
=
 
Should evaluate to a profile object, or the name or guid of a profile May use liquid filters.
%}

Fetches a single profile.

Related

{{ profile }}

{% profiles %}

{{ profiles }}

Contains multiple profiles.

{% profiles %}

{% profiles output_to_template? [[var, set, or assign]? variable]? output_to_template? = arguments %}

{% profiles
output_to_template
 
If included the profiles will be output directly to the template.
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this profiles is stored on. "var" is the default behavior.
variable
output_to_template
 
If included the profiles will be output directly to the template.
=
arguments
 
Key:value pairs. May use the variable arguments syntax.
%}

arguments

prepend
 
May be a single profile, a list of profiles, or the name or guid of a profile to be be included at the beginning of the profiles.
append
 
May be a single profile, a list of profiles, or the name or guid of a profile to be be included at the end of the profiles.
exclude
 
May be a single profile, a list of profiles, or the name or guid of a profile that should NOT be included in the fetched results. Has no affect on prepended or appended profiles.
exclude_prepended
 
True to specifically exclude all prepended profiles from the fetched results. If "unique:true" is specified this is the default behavior, although you may also specify "exclude_prepended:false" to allow any prepended items to be fetched along with other results anyway.
exclude_appended
 
True to specifically exclude all appended profiles from the fetched results. This is false by default - even if "unique:true" is specified - so that results are returned in the proper order.
unique
 
True to remove duplicates from each of the resulting lists (prepended, fetched, appended, and items), although there may be duplicates between the prepended, fetched, and appended lists. The "items" list will include objects in the order in which they appear - with prepended items first, then fetched items, then appended items.
max_size
 
The maximum number of items to be included in the "items" list. If there are any prepended or appended items, this will automatically lower the "limit" to only fetch as many profiles as needed. Note that this may also impact both the "page" and "total_pages" values in the resulting profiles. In order to use pagination with a list loaded using "max_size" use "start" instead of "page" and "limit".
filter
 
Only include profiles that match the given string filter
is_active
 
only include profiles that either are or are not active
is_blocked
 
Only include profiles that either are or are not blocked
query
 
Only include profiles whose settings match the given query. Profile queries share the same advanced syntax as datastore item queries, which may be reviewed at https://help.marketpath.com/liquid/advanced-datastore-queries
attributes
 
Only include profiles whose attributes match the given query. Profile queries share the same advanced syntax as datastore item queries, which may be reviewed at https://help.marketpath.com/liquid/advanced-datastore-queries
date_logged_in_start
 
Only include profiles with date_last_logged_in greater than or equal to date_logged_in_start
date_logged_in_end
 
Only include profiles with date_last_logged_in less than or equal to date_logged_in_end
date_created_start
 
Only include profiles with date_created greater than or equal to date_created_start. Remember that date_created will typically be the date that the profile was first published.
date_created_end
 
Only include profiles with date_created less than or equal to date_created_end. Remember that date_created will typically be the date that the profile was first published.
start
 
Set the 1-based index of the first profile to fetch.
page
 
Used to automatically calculate the first profile to fetch based on both the "limit" and the 1-based "page" value. Defaults to 1, but is ignored if "start" is set.
limit
 
The maximum number of profiles to fetch. Defaults to 10. Note that if "max_size" is defined, then "limit" may be automatically lowered even if specified separately.
sort_by
 
Specify which property to sort the results by. Has no affect on prepended or appended profiles. By default, results will be sorted by relevance if there is a filter string and date_created desc (newest first) if not. Options include:
  • relevance: only applies when there is a filter string. When sorting by relevance sort_direction is ignored.
  • date_created: the date each profiles was first published. Unpublishing and republishing a profiles resets date_created to the current date.
  • random: results will be returned in a random order, which prevents the page from being fast-cached. Setting cache_random:true overrides this behavior and allows the page to be fast-cached anyway.
  • name
  • title
  • url
  • browser_title
sort_direction
 
asc or desc.
cache_random
 
True to allow the results to be cached when sort_by is "random".

Fetches a list of profiles.

Related

{% profile %}

{{ profile }}

{{ profiles }}

Contains multiple profiles.

{% set_profile %}

Saves custom properties on the profile that will be accessible whenever the current profile is logged in. The properties will be saved to the profile's attribute dictionary. Note that this is meaningless unless the user is logged in.

{% set_profile attributes %}

{% set_profile
attributes
 
Key:value pairs with unique keys. May use the variable arguments syntax.
%}

Related

{% set_title %}

Sets the page title.

{% set_description %}

Sets the meta description for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{% set_session %}

Saves custom properties on the session. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.

{% profile %}

{% set_timezone %}

Sets the default timezone to use when rendering dates and times on the page that do not already have a separate timezone configured.

{% set_content_type %}

Sets the Content-Type header for the HTTP response.

{% set_robots %}

Sets the robots meta directive.

{% unset_profile %}

Removes custom properties from the attribute dictionary of the currently logged-in profile. Note that this is meaningless unless the user is logged in.

{% set_client %}

Saves custom properties on the client that will survive across multiple sessions until they are changed, unset, or the "session" permission expires. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.

{% set_favicon %}

Sets the URL to the favicon for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{% set_profile_setting %}

Saves custom values to predefined profile settings that will be accessible whenever the current profile is logged in. Note that this is meaningless unless the user is logged in. Profile settings may include validation, in which case all settings will be validated before being set and any validation error will prevent the setting(s) from being set. Validation errors may optionally be output to a variable.

{{ profile }}

{% unset_profile_setting %}

Removes custom values from the profile settings for the currently logged-in profile. Note that this is meaningless unless the user is logged in. For settings with a default value this will reset them to the default, and for all other settings this will set them to empty/unselected/false. Profile settings may be required and include validation, in which case all settings will be validated before being removed and any validation error will prevent any settings from being set. Validation errors may optionally be output to a variable.

{% set %}

Replaces a value on the nearest scope where it has already been defined. If it has not been defined yet, it is stored on the root scope.

{% set_header %}

Sets one or more headers in the HTTP response.

{% set_client_permission %}

Defines whether the client has granted or deined permission for a particular feature (eg: sessions). The only permission defined by default is the session permission (configurable in the site properties). However, the template developer may use this mechanism for their own purposes as well. The permissions defined by this method will be stored in the permissions cookie, which may be read and/or modified by client-side javascript.

{% set_dictionary %}

Sets properties on an editable dictionary object. If the dictionary does not exist it will be created and stored on the current scope. If the dictionary exists but is not editable this will throw an error.

{% set_cookie %}

Sets a cookie in the HTTP response.

{% set_canonical_url %}

Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{% set_response_code %}

Sets the HTTP response status code.

{% unset_profile %}

Removes custom properties from the attribute dictionary of the currently logged-in profile. Note that this is meaningless unless the user is logged in.

{% unset_profile attributes %}

{% unset_profile
attributes
 
One or more values. May use the variable arguments syntax.
%}

There is no option to unset all attributes from a profile - attributes must be removed by name.

Related

{% unset_dictionary %}

Removes properties from an editable dictionary object. If the dictionary does not exist an empty one will be created and stored on the current scope. If the dictionary exists but is not editable this will throw an error.

{% unset_session %}

Removes custom properties from the session.

{% profile %}

{% unset_client %}

Removes custom properties from the client.

{% unset_client_permission %}

Removes the specified permissions from the permissions cookie. Note that this is not the same as denying permission since there will be no record that permission was either granted or denied after the permission has been unset.

{% set_profile_setting %}

Saves custom values to predefined profile settings that will be accessible whenever the current profile is logged in. Note that this is meaningless unless the user is logged in. Profile settings may include validation, in which case all settings will be validated before being set and any validation error will prevent the setting(s) from being set. Validation errors may optionally be output to a variable.

{{ profile }}

{% unset_profile_setting %}

Removes custom values from the profile settings for the currently logged-in profile. Note that this is meaningless unless the user is logged in. For settings with a default value this will reset them to the default, and for all other settings this will set them to empty/unselected/false. Profile settings may be required and include validation, in which case all settings will be validated before being removed and any validation error will prevent any settings from being set. Validation errors may optionally be output to a variable.

{% unset_cookie %}

"Unsets" one or more cookies. Because of how cookies work, this will actually ADD the cookie to the response with an expiration date in the past.

{% set_profile %}

Saves custom properties on the profile that will be accessible whenever the current profile is logged in. The properties will be saved to the profile's attribute dictionary. Note that this is meaningless unless the user is logged in.

{% set_profile_setting %}

Saves custom values to predefined profile settings that will be accessible whenever the current profile is logged in. Note that this is meaningless unless the user is logged in. Profile settings may include validation, in which case all settings will be validated before being set and any validation error will prevent the setting(s) from being set. Validation errors may optionally be output to a variable.

{% set_profile_setting [[var, set, or assign]? errors=variable]? properties %}

{% set_profile_setting
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this set_profile_setting is stored on. "var" is the default behavior.
errors=
variable
 
The variable to save validation errors to. Validation errors will be specified as a list of Key:Value pairs, or null if there are no validation errors.
properties
 
Key:value pairs with unique keys. May use the variable arguments syntax. The settings to set on the profile. Each property key should match a setting id, and the property value will be used for the setting value
%}

Related

{% set_title %}

Sets the page title.

{% auth set_setting %}

Sets the specified profile settings to their new values on the auth profile (which is not necessarily the same as the currently-logged in profile). If any of the specified settings has validation, the new settings will be validated before being set. An invalid value for any setting will prevent any of the new settings from being set. If the profile exists and the auth is not aborted before the end of the request the new values will be saved to the profile. If the auth is aborted then the new values will not be saved in between requests. If the profile does not exist but is registered in the same request then the new values will be saved on the new profile.

{% set_description %}

Sets the meta description for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{% set_session %}

Saves custom properties on the session. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.

{% auth unset_setting %}

Unsets the specified profile settings from the auth profile (which is not necessarily the same as the currently-logged in profile). For settings with default values this will set them back to their defaults. For settings without default values this will set them to empty/unselected/false. If any of the specified settings is required, it will result in an invalid_value error and will prevent any of the new settings from being unset. If the auth is aborted then the unset settings will not be saved in between requests.

{% profile %}

{% set_timezone %}

Sets the default timezone to use when rendering dates and times on the page that do not already have a separate timezone configured.

{% set_content_type %}

Sets the Content-Type header for the HTTP response.

{% set_robots %}

Sets the robots meta directive.

{% unset_profile %}

Removes custom properties from the attribute dictionary of the currently logged-in profile. Note that this is meaningless unless the user is logged in.

{% set_client %}

Saves custom properties on the client that will survive across multiple sessions until they are changed, unset, or the "session" permission expires. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.

{% set_favicon %}

Sets the URL to the favicon for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{{ profile }}

{% unset_profile_setting %}

Removes custom values from the profile settings for the currently logged-in profile. Note that this is meaningless unless the user is logged in. For settings with a default value this will reset them to the default, and for all other settings this will set them to empty/unselected/false. Profile settings may be required and include validation, in which case all settings will be validated before being removed and any validation error will prevent any settings from being set. Validation errors may optionally be output to a variable.

{% set %}

Replaces a value on the nearest scope where it has already been defined. If it has not been defined yet, it is stored on the root scope.

{% set_header %}

Sets one or more headers in the HTTP response.

{% set_client_permission %}

Defines whether the client has granted or deined permission for a particular feature (eg: sessions). The only permission defined by default is the session permission (configurable in the site properties). However, the template developer may use this mechanism for their own purposes as well. The permissions defined by this method will be stored in the permissions cookie, which may be read and/or modified by client-side javascript.

{% set_dictionary %}

Sets properties on an editable dictionary object. If the dictionary does not exist it will be created and stored on the current scope. If the dictionary exists but is not editable this will throw an error.

{% set_cookie %}

Sets a cookie in the HTTP response.

{% set_canonical_url %}

Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{% unset_profile_setting %}

Removes custom values from the profile settings for the currently logged-in profile. Note that this is meaningless unless the user is logged in. For settings with a default value this will reset them to the default, and for all other settings this will set them to empty/unselected/false. Profile settings may be required and include validation, in which case all settings will be validated before being removed and any validation error will prevent any settings from being set. Validation errors may optionally be output to a variable.

{% unset_profile_setting [[var, set, or assign]? errors=variable]? properties %}

{% unset_profile_setting
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this unset_profile_setting is stored on. "var" is the default behavior.
errors=
variable
 
The variable to save validation errors to. Validation errors will be specified as a list of Key:Value pairs, or null if there are no validation errors.
properties
 
One or more values. May use the variable arguments syntax. The ids of the settings to remove from the profile
%}

There is no option to unset all settings on a profile - settings must be unset by name.

Related

{% unset_dictionary %}

Removes properties from an editable dictionary object. If the dictionary does not exist an empty one will be created and stored on the current scope. If the dictionary exists but is not editable this will throw an error.

{% unset_session %}

Removes custom properties from the session.

{% auth set_setting %}

Sets the specified profile settings to their new values on the auth profile (which is not necessarily the same as the currently-logged in profile). If any of the specified settings has validation, the new settings will be validated before being set. An invalid value for any setting will prevent any of the new settings from being set. If the profile exists and the auth is not aborted before the end of the request the new values will be saved to the profile. If the auth is aborted then the new values will not be saved in between requests. If the profile does not exist but is registered in the same request then the new values will be saved on the new profile.

{% auth unset_setting %}

Unsets the specified profile settings from the auth profile (which is not necessarily the same as the currently-logged in profile). For settings with default values this will set them back to their defaults. For settings without default values this will set them to empty/unselected/false. If any of the specified settings is required, it will result in an invalid_value error and will prevent any of the new settings from being unset. If the auth is aborted then the unset settings will not be saved in between requests.

{% profile %}

{% unset_client %}

Removes custom properties from the client.

{% unset_client_permission %}

Removes the specified permissions from the permissions cookie. Note that this is not the same as denying permission since there will be no record that permission was either granted or denied after the permission has been unset.

{% unset_profile %}

Removes custom properties from the attribute dictionary of the currently logged-in profile. Note that this is meaningless unless the user is logged in.

{% set_profile_setting %}

Saves custom values to predefined profile settings that will be accessible whenever the current profile is logged in. Note that this is meaningless unless the user is logged in. Profile settings may include validation, in which case all settings will be validated before being set and any validation error will prevent the setting(s) from being set. Validation errors may optionally be output to a variable.

{{ profile }}

{% unset_cookie %}

"Unsets" one or more cookies. Because of how cookies work, this will actually ADD the cookie to the response with an expiration date in the past.

{% set_profile %}

Saves custom properties on the profile that will be accessible whenever the current profile is logged in. The properties will be saved to the profile's attribute dictionary. Note that this is meaningless unless the user is logged in.

Examples

Demonstrates how to set Profile.

Set Profile

Copy
{% if submission.is_valid %}
{% var bestScoreName = form.name.value | classname | prepend:'bestscore-' %}
{% var bestScore = submission.score | to_int %}
{% var previousBestScore = profile.attributes[bestScoreName] | to_int %}
{% if previousBestScore > bestScore %}
{% set bestScore = previousBestScore %}
{% endif %}
{% set_profile last_score:submission.score &bestScoreName:bestScore %}
{% endif %}

Saves custom values to predefined profile settings that will be accessible whenever the current profile is logged in. Profile settings may include validation, in which case all settings will be validated before being set and any validation error will prevent the setting(s) from being set. Validation errors may optionally be output to a variable.

How to use the set_profile_setting method

Copy

Simple Use Case

{% if submission.is_valid and submission.score > 70 %}
{% set_profile_setting passed_test:'true' %}
{% endif %}
Stores a value in the "passed_test" profile setting. Does not check if the user is currently logged in, verify that the "passed_test" setting is valid, or check for other errors. If the user is not logged in or the setting is not valid, it simply won't be saved.

Use Case with Validation

{% var new_layout = request.post_params['layout'] %}
{% var new_companyname = request.post_params['companyname'] %}
{% var new_description = request.post_params['description'] %}
{% set_profile_setting var errors = profile_errors layout:new_layout companyname:new_companyname description:new_description %}
{% if profile_errors %}
{% for error in profile_errors %}
<p class="error">Error saving <strong>{{error.Key}}</strong>: {{error.Value}}</p>
{% endfor %}
{% endif %}
Stores the values of the "layout", "companyname", and "description" form fields in the profile settings. If any of the settings are invalid, the errors are saved to the "profile_errors" variable and displayed to the user.

Demonstrates how to unset Profile Setting.

Unset Profile Setting

Copy
{% if request.post_params.clear_description %}
{% unset_profile_setting description %}
{% endif %}

Simple Use Case

{% if request.post_params.clear_description %}
{% unset_profile_setting description %}
{% endif %}
Unsets the "description" profile setting if the "clear_description" post parameter is present.

Unset Multiple Profile Settings at Once

{% if submission.is_valid and submission.score.value < 80 %}
{% unset_profile_setting passed_certification_exam certification_category %}
{% endif %}
Unset multiple profile settings at the same time. In this example, the template will unset the "passed_certification_exam" and "certification_category" settings if the submission is valid and the score is less than 80.

Unset Profile Settings Dynamically with Validation

{% var clearsettings = request.post_params.clearsettings | split: ',' | join:' ' %}
{% var profile_errors = null %}
{% if clearsettings is_valid %}
{% unset_profile_setting set errors = profile_errors *clearsettings %}
{% if profile_errors %}
{% for error in profile_errors %}
<p class="error">Error clearing <strong>{{error.Key}}</strong>: {{error.Value}}</p>
{% endfor %}
{% endif %}
{% endif %}
Checks if the "clearsettings" post parameter was included in the request, and if it was, converts the comma-delimited list of setting names to a space-delimited list and unsets the profile settings with those names using the expanded variable syntax. If any of the settings are invalid, the errors are saved to the "profile_errors" variable and displayed to the user.

Demonstrates how to unset Profile.

How to use the unset_profile method

Copy

Simple Use Case

{% if request.query_params.hide_the_money %}
{% unset_profile show_me_the_money %}
{% endif %}
Removes the "show_me_the_money" profile property if the "hide_the_money" query parameter is present.

Unset Profile Properties Dynamically

{% var clearprops = request.query_params.clearprops | split: ',' | join:' ' %}
{% if clearprops is_valid %}
{% unset_profile *clearprops %}
{% endif %}
Checks if the "clearprops" query parameter was included in the request, and if it was, converts the comma-delimited list of property names to a space-delimited list and unsets the profile properties with those names using the expanded variable syntax.

Unset Multiple Profile Properties

{% if submission.is_valid and submission.score.value < 80 %}
{% unset_profile passed_certification_exam user_is_certified_for_x %}
{% endif %}
Unset multiple profile properties at the same time. In this example, the template will unset the "passed_certification_exam" and "user_is_certified_for_x" properties if the submission is valid and the score is less than 80.