RulesEngine (WordPress)

RulesEngine is a wordpress plugin used for defining rules for wordpress components such as Pages, Posts, Categories,
Themes, Widgets and URL Redirection.

RulesEngine follows “define once and use in many ways” strategy, which
enables admin to define the logical rule at once by using rule criteria such as User Role, User Profile, Mobile
Device, Tablet, Geo location, Date and Time, Request URL, Browser Type etc and uses them in defining the child rules
like Page, Post, Category, Theme, Widget and URL Redirection.

RulesEngine consists of a parent rule called the Logical
Rule
and 6 child rules. Following are the list of child rules:

Click on the above links to know more about RulesEngine. In future releases many more rules are planned.

  1. Page Rules
  2. Post Rules
  3. Category
    Rules
  4. Widget Rules
  5. Theme Rules
  6. Rules for URL
    Redirection

Click here for RulesEngine video tutorial.

Click here for RulesEngine demos.

A logical rule is defined by 9 different categories like User Role, User Profile, Pages, Posts Geo location etc, 21
subcategories like Email, Registered Date, Country, Date and Time etc and with 8 conditions like equals, not equal,
greater than etc.

Click here to view the complete list of
categories and subcategories.

Many more categories and subcategories are planned in future releases.

What we can solve using RuleEngine?

We can solve a very vast set of use cases using RuleEngine.
Watch Video Tutorials to know more about RulesEngine

Below are few commonly used use cases.

  • Hide Pages/Posts/Categories/Widgets by User Role: Show or hide pages, posts, categories,
    widgets for a specific user role.
  • Hide Pages/Posts/Categories/Widgets from Guest User : Hide some pages, posts, categories,
    widgets from Guest user.
  • Simple Ad Manager: Page or Post rule defined with images will act like a simple Ad manager.
    Using this rule we can use an Ad image with a logical rule defined with Date/Page/Geographic location etc to
    show image Ad on respective Pages or Posts.
  • Pages by Date and Time: Show special pages like “New Year” or “Christmas”
    or “Year End Sales” discounts page and make them available for only few days or months.
  • Pages by Geo Location: Hide or append information for request which are coming from a specific
    geographic location country or continent.
  • Restricted Pages: These page are available only authenticated users, guest users will be
    redirected to login page.
  • Show Greetings or Important messages: Using RulesEngine we can show greetings or important
    message such as new year wishes or festival wishes or System downtime.
  • Themes by Geo Location: Using RuleEngine, we can show a different Theme for a specific
    geographic location country or continent then define a logical rule using “Geo Location” Criteria. This is
    useful for theme is very useful for Middle East countries.
  • Themes by Date and Time: Using RuleEngine, we can show a different Theme on special themes on
    “New Year” or “Christmas” etc… , and these theme should
    be available for only few days or months, in such cases define a Logical rule using “Date and
    Time”
    criteria.
    You can use Date, Time, Day of Week and Month sub criteria to further refine the rule.
  • Theme for Guest User : Show a fancy theme for a Guest user(Not logged in User) and default
    theme for logged in user.
  • Themes by Device Type: Show a light weight theme for Mobile and Tablet devices and default
    theme for desktop users.
  • Themes by User Role: Show a different theme for a specific role.
  • Redirect for Mobile Sites:Redirect to mobile sites
    for requests coming from mobile or tablet devices.
  • Redirect Secure Pages : We can configure Pages as Secure pages and these pages content will be
    shown only for authenticated users. Guest users will be redirected to Login Page upon clicking on Secure Pages.

How we can solve a use case?

Below is the example of Pages By Role hiding of page for a user with “Subscriber Role”.

  • We can define simple logical rule like role as Subscriber (see below screenshot)

  • Simple_Rule

  • Below screenshot depicts how we can leverage a “Subscriber Rule” Logical rule for defining rules for Pages.
    Below rule is used for hiding “Ad Manager” and “Contact Us” Pages for users with Subscriber role.

  • SubscriberHiddenPages

    We can further use the same “Subscriber Role” logical rule to define other child rules (Posts, Categories, Theme etc).

Defining a complex rule.

  • RulesEngine is very flexible for defining very complex logical rules using “AND” “OR” and “Brackets” operators.
    (e.g: Role is Administrator and Country is USA and Month is January, Page is Home etc, see below sreenshots.)
    See Logical rule section for more info.

  • \


    RulesEngine also provides an utility method through which we can get the evaluated logical rule value in a single statement.

    RulesEngine::is_rule_valid(“Logical Rule Name”);

if(RulesEngine::is_rule_valid("USA and Asia Rule")) {
    echo "Condition satisfied";
}
where "USA and Asia Rule" is the name of the Logical Rule.

RulesEngine makes code very easy to maintain. we can add or update values in rule condition without modifying code.

Below is the code representation of above complex logical Rule. This code is hard to maintain and
we need a developer to update the below logic.


if(($month === "January" || $month === "December") &&
    ($country === "United States" || $continent === "Asia") &&
    ($user_profile === $login_status || $user_role !== "Administrator") &&
    ($page_title === "home")) {

    echo "Condition satisfied";
}

Important Features

  • Define simple rule like role as Administrator.
  • Define complex rule using logical “AND” “OR” and “Brackets” . (e.g: like role is Administrator and Country is
    USA and Month is January etc, see above sreenshots.)
    See Logical rule section for more info.
  • Hide menus.
  • Hide, show, append or replace content for Pages.
    more info.
  • Hide, show, append or replace content for Posts.
    more info.
  • Add dynamic content to Pages and Posts.
  • Add dynamic images to Pages and Posts.
  • Generate dynamic Shortcode for Page and Post rules, so that we can add dynamic
    content/image at any desired location on Page or Post.
  • Show or Hide Categories.
    more info.
  • Show or Hide Widgets.
    more info.
  • Show a different Themes for users, roles or on a specific day or county etc. more info.
  • Redirect to a different Page or Site.
    more info.
  • Define a dynamic hook using Rules Engine which will be called by plugin once the rule is satisfied.
  • Access the status of the Logical Rule using the utility method from your code.
    <strong>RulesEngine::is_rule_valid("Rule Name");</strong>
  • User Friendly easy-to-use Ajax interface.
  • Reduces development effort and easy to maintain
  • Activate or Deactivate Parent Rule (Logical Rule) and Child rules (Page, Post, Theme Rules etc).
    If Parent Rule is deactivated all the corresponding child rules will become inactive.
  • Easy to upgrade.

Download RulesEngine (WordPress)

Leave a Reply

Your email address will not be published. Required fields are marked *