Preferences offer a nice a way to change the UI based on. For the most part they control the internal UI, however this data can also be used in the backend. In our examples we are going to be creating a custom preference named
custom_preference. Join us as we extend the Preferences of Cornerstone.
All preference data is stored in usermeta under
cs_app_preferences as a serialized associative array. It initially uses the defaults unless set by a user.
Changing the Default Preferences
cs_app_preference_defaults can be used to change the default preferences
The preference ui controls can be extend through the filter
cs_preference_controls. Adding a new group or item is preferred to adding to one of the built in Cornerstone groups. In the future a function to combine the actions of setting defaults and adding controls will be created to streamline this setup.
@since CS 7.4.0
The following helper functions are offered to interact with the Preference data. Sending
null to any of the functions that have a
$user_id parameter will result in using the current users preferences.
Preference Function Sample
The following is a basic example using the preference we created earlier
See something inaccurate? Let us know