{"id":6298,"date":"2020-09-04T00:32:32","date_gmt":"2020-09-04T00:32:32","guid":{"rendered":"https:\/\/the7kennisbank.nl\/uncategorized\/custom-filters-wp-brain\/"},"modified":"2020-09-04T00:55:40","modified_gmt":"2020-09-04T00:55:40","slug":"custom-filters-wp-brain","status":"publish","type":"post","link":"https:\/\/the7kennisbank.nl\/en\/wp-brain\/custom-filters-wp-brain\/","title":{"rendered":"Custom Filters \u2013 WP Brain"},"content":{"rendered":"
<\/p>\n
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.<\/p>\n
<\/p>\n
The filters are based on common data sources used by marketing experts and web developers like form fields, URL parameters, cookies, functions etc.<\/p>\n
This name is used as a label in the rules builder\u2019s filters dropdown list, It will appear under the \u201cCustom\u201d section of the list.<\/p>\n
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:<\/p>\n
For each user, WordPress store the profile details as metadata, for example the first and the last name, there\u2019s also a lot of plugin that use these metadata to provide custom user profiles.<\/p>\n
By using this data source, you can segement your members and targeting the users who only have a meta value that meet your conditions<\/p>\n
The same for users, WordPress also use metadata for posts to store any custom fields related to that post or page, but it\u2019s used by third party themes and plugin to add custom details about the posts and to change their layout and styles<\/p>\n
In some cases, It\u2019s very useful to use these values to control the content visibility based on custom post fields<\/p>\n
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.<\/p>\n
For more information about these variables and the data keys you can use, please check the official WordPress query vars<\/a> guide.<\/p>\n 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.<\/p>\n Thanks to WP Brain, you don\u2019t 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.<\/p>\n For example, let\u2019s take this sample link 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.<\/p>\n This advanced data source allow you to build conditions based on the defined PHP constants, please check the WordPress constants overview<\/a> and the PHP Predefined Constants<\/a> for more details about the constants usuage.<\/p>\n 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<\/a> but can be used also with stantard PHP functions or third party plugins functions.<\/p>\n 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<\/a> to get an idea about the available choises.<\/p>\n I guess there\u2019s no one who doesn\u2019t recognize cookies or sessions, they work almost the same, they have been used widely for tracking vistors accross the website pages.<\/p>\n With the help of this WP Brain feature, you can easily filter the content of your website using the value of these cookies.<\/p>\n 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<\/a>, you can use all these keysto create your custom filters.<\/p>\n 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<\/a><\/p>\n After selecting a data source, the filters manager need to know the type of the value returned by the data source:<\/p>\nURL variables:
$_GET<\/code><\/h4>\n
http:\/\/example.com\/?color<\/strong>=purple<\/code>, If a visitor access your website using that URL, you can show them anything base the color<\/strong> variable<\/p>\n
Form fields:
$_POST<\/code><\/h4>\n
PHP constant<\/h4>\n
PHP function<\/h4>\n
PHP variable:
$GLOBALS<\/code><\/h4>\n
Cookies and Session<\/h4>\n
Environment variables:
$_ENV<\/code><\/h4>\n
Server variables:
$_SERVER<\/code><\/h4>\n
Data Types<\/h3>\n