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.

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