{"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

\"custom<\/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

Filter Name<\/h3>\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

Data Sources<\/h3>\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

User metadata<\/h4>\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

Post metadata<\/h4>\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

Query mariable<\/h4>\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

URL variables: $_GET<\/code><\/h4>\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 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

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

PHP constant<\/h4>\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

PHP function<\/h4>\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

PHP variable: $GLOBALS<\/code><\/h4>\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

Cookies and Session<\/h4>\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

Environment variables: $_ENV<\/code><\/h4>\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

Server variables: $_SERVER<\/code><\/h4>\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

Data Types<\/h3>\n

After selecting a data source, the filters manager need to know the type of the value returned by the data source:<\/p>\n

    \n
  1. String<\/li>\n
  2. Integer<\/li>\n
  3. Double<\/li>\n
  4. Date<\/li>\n
  5. Time<\/li>\n
  6. Boolean<\/li>\n
  7. Version<\/li>\n<\/ol>\n

    Please refer to the condition builder documentation<\/a> to learn more about these types and the related operators.<\/p>\n

    Data Key<\/h3>\n

    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.<\/p>\n

    Builder Actions<\/h3>\n

    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.<\/p>\n

    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.<\/p>\n

    \n

    Note:<\/h4>\n

    The Export<\/strong> functions wont consider the unsaved changes and will work with the latest saved data, so please save your changes before using the export buttons.<\/p>\n<\/div>\n

    \n

    Note:<\/h4>\n

    The Import<\/strong> button wont save automatically the imported filters so you have to click save once you are sure about the result of the import process.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

      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…<\/p>\n","protected":false},"author":2,"featured_media":6333,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[58],"tags":[],"class_list":["post-6298","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wp-brain","category-58","description-off"],"acf":[],"_links":{"self":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/6298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/comments?post=6298"}],"version-history":[{"count":3,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/6298\/revisions"}],"predecessor-version":[{"id":6362,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/6298\/revisions\/6362"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/media\/6333"}],"wp:attachment":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/media?parent=6298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/categories?post=6298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/tags?post=6298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}