Views - Conditions

SleekView's powerful conditions system allows you to control when views, tabs, and individual switches should be active or visible. This is particularly useful when views are embedded on the frontend or when you need role-based access control.

How Conditions Work

Every view and most switches within view configurations support custom conditions. These conditions determine whether the feature should be active based on the current environment, user, or context.

Setting Conditions

When you see a "Set conditions" button next to a switch or in a view's settings, you can click it to open the conditions interface. This interface uses an AND/OR repeater system for building complex logic:

  • Multiple conditions within a group are connected with AND (all must be true)
  • Multiple groups are connected with OR (at least one group must be true)

Available Parameters

Environment

Is Admin

Determines whether the view is being displayed in the WordPress admin area or on the frontend. This is particularly useful for views that can be embedded via shortcode.

  • is equal to true: Show only in admin area
  • is equal to false: Show only on frontend (embedded views)

User

User

Filter by specific user ID. Useful for creating personalized views for individual users.

User Role

Filter by WordPress user role (e.g., Administrator, Editor, Author). This allows you to show different features to different user groups.

Examples

Admin-Only Editing

You might want to allow editing in the admin but disable it on the frontend:

  • Parameter: Is Admin
  • Operator: is equal to
  • Value: true

This would make the "Show edit button" only appear when the view is displayed in the WordPress admin.

Role-Based Features

Show upvotes only to logged-in users with specific roles:

  • Parameter: User Role
  • Operator: is equal to
  • Value: subscriber

Complex Conditions

You can combine multiple conditions for more sophisticated logic. For example, to show a feature only to administrators in the admin area:

Group 1 (AND)

  • Parameter: Is Admin
  • Operator: is equal to
  • Value: true

AND

  • Parameter: User Role
  • Operator: is equal to
  • Value: administrator

View-Level Conditions

Every view has a Conditions section at the bottom of its configuration panel. These conditions control the entire view's visibility. If the conditions aren't met, the view tab won't appear at all.

Switch-Level Conditions

Individual switches within view configurations can also have conditions. For example:

  • Show upvotes: Set conditions to only show upvotes on the frontend
  • Show edit button: Set conditions to only show for administrators
  • Show add button: Set conditions to disable adding in embedded views
  • Show comments: Set conditions based on user roles

Best Practices

  1. Frontend vs Admin: Use "Is Admin" conditions to differentiate between admin and frontend behavior
  2. Progressive Enhancement: Start with basic functionality for all users, then add conditions for advanced features
  3. Test Both Contexts: When using "Is Admin" conditions, test both in the admin area and via shortcode embeds
  4. Role-Based Access: Use User Role conditions to create different experiences for different user types

Conditions provide incredible flexibility in how your views behave in different contexts, making SleekView adaptable to virtually any content management scenario.