Set_profile_setting

Set_profile_setting

{% 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
%}

Examples

Set Profile Setting 1

Copy
{% if submission.is_valid and submission.score > 70 %}
{% set_profile_setting passed_test:'true' %}
{% endif %}

Set Profile Setting 2

Copy
{% 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 %}