Unset_profile_setting

Unset_profile_setting

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

Examples

Unset Profile settings dynamically

Copy
{% var clearsettings = request.post_params.clearsettings | split: ',' | join:' ' %}
{% if clearsettings is_valid %}
{% unset_profile var 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 %}

Unset Profile Setting

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