By using the custom filters manager tool bundled within WP Brain settings page, you will be able to extend the logic validator with your own filters without writing a line of code.
The filters are based on common data sources used by marketing experts and web developers like form fields, URL parameters, cookies, functions etc.
Filter Name
This name is used as a label in the rules builder’s filters dropdown list, It will appear under the “Custom” section of the list.
Data Sources
To create custom filters you need to select the data source from where the validator will fetch the current value that will be compared in the condition, there are many to choose from:
User metadata
For each user, WordPress store the profile details as metadata, for example the first and the last name, there’s also a lot of plugin that use these metadata to provide custom user profiles.
By using this data source, you can segement your members and targeting the users who only have a meta value that meet your conditions
Post metadata
The same for users, WordPress also use metadata for posts to store any custom fields related to that post or page, but it’s used by third party themes and plugin to add custom details about the posts and to change their layout and styles
In some cases, It’s very useful to use these values to control the content visibility based on custom post fields
Query mariable
The WordPress query vars are related to the current page query settings, while a page or post is beeing queried from the database, WordPress store a lot of details in the global query object, so you can access them by creating a filter with this data source.
For more information about these variables and the data keys you can use, please check the official WordPress query vars guide.
URL variables: $_GET
Also referenced query strings, the URL variables are very important for marketing as they help adding more details to your links, and you can easily access then with any scripting language.
Thanks to WP Brain, you don’t have to use any coding language to use these variables, just create a custom filter with the needed key and you are ready to go.
For example, let’s take this sample link http://example.com/?color=purple
, If a visitor access your website using that URL, you can show them anything base the color variable
Form fields: $_POST
When a visitor submit a form, you can use this custom filter to catch the form fields values and display custom content based on what he enetered in the form inputs.
PHP constant
This advanced data source allow you to build conditions based on the defined PHP constants, please check the WordPress constants overview and the PHP Predefined Constants for more details about the constants usuage.
PHP function
Functions are considered the base of any programming language, and WP Brain make the usage of them as easy as a click. you can use any avalable function that return a value but do not require any arguments, this data source is intended to be used for the WordPress Conditional Tags but can be used also with stantard PHP functions or third party plugins functions.
PHP variable: $GLOBALS
The variables in PHP are used to store different values during the page runtime, if you know a global variable name, you can control the visibility of your content using this custom filter source. you can see more details about the WordPress global variables to get an idea about the available choises.
Cookies and Session
I guess there’s no one who doesn’t recognize cookies or sessions, they work almost the same, they have been used widely for tracking vistors accross the website pages.
With the help of this WP Brain feature, you can easily filter the content of your website using the value of these cookies.
Environment variables: $_ENV
Only for advanced users, the environment variables are set by the server and may contain very usefull details about the vistors, you can read more in the PHP docs, you can use all these keysto create your custom filters.
Server variables: $_SERVER
The server variable are also set by the server and contain a lot of details about the current request, like the IP address, the referer site, etc. the full list is available in the official PHP documentation
Data Types
After selecting a data source, the filters manager need to know the type of the value returned by the data source:
- String
- Integer
- Double
- Date
- Time
- Boolean
- Version
Please refer to the condition builder documentation to learn more about these types and the related operators.
Data Key
The key is the identifier of the value within the chosen data source: array index, object index, function name, etc. The key is also used as an ID to identify this filter within the other registered filters.
Builder Actions
At the right of each line that represent a custom filter, we find two buttons: one blue for exporting single filters, and the other red cross to delete that filter.
At the bottom of the lines, we have three buttons: the green allow you to ad new filters, while the orange one will help you import your exported custom filters. Finally, the blue button function as a bulk export and it will export all the filters and give the code for later importation.
Note:
The Export functions wont consider the unsaved changes and will work with the latest saved data, so please save your changes before using the export buttons.
Note:
The Import button wont save automatically the imported filters so you have to click save once you are sure about the result of the import process.