Add Conditional Statements to your post content e.g. IF the user is logged in display "Welcome back!"
Author: | YeKen (profile at wordpress.org) |
WordPress version required: | 4.2.0 |
WordPress version tested: | 5.2.2 |
Plugin version: | 1.0 |
Added to WordPress repository: | 10-07-2019 |
Last updated: | 10-07-2019
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|
Rating, %: | 0 |
Rated by: | 0 |
Plugin URI: | |
Total downloads: | 307 |
Active installs: | 10+ |
Click to start download |
Conditional Statements allows you to add logic into your pages. The plugin supports various conditions allowing you to apply IF statements.
For example: “IF the user is logged in display X ELSE display Y” would look like:
[cs-if conditions=”is-logged-in”]
Welcome Back!
[else]
You must be logged in to view the gallery.
[/cs-if]
You can also nest conditions e.g.
[cs-if conditions=”is-logged-in”]
The user is logged in.
[cs-if-1 conditions=”firstname”]
The user has entered a first name!
[else-1]
The user must enter a first name!
[/cs-if-1]
[cs-if-1 conditions=”lastname”]
The user has entered a last name!
[else-1]
The user must enter a last name!
[/cs-if-1]
[/cs-if]
Simply add a hyphen and the depth (up to a maximum of 5) e.g. [cs-if-1], [cs-if-2], [cs-if-3] and so on.
Examples
Please look at these examples on how to use the Conditional Statements shortcode:
Examples of how to use Conditional Statements
Features
- Supports nesting of IF statements (upto 5 deep)
- AND logic. If you specify more than one condition, the conditions are AND’d (e.g. all conditions must be met for the condition to be true)
- ELSE conditions
- Comparisons e.g. “does the post type equal ‘article'”
[cs-if conditions=”post-type” operator=”equals” compare-value=”article”]
Post Type is Article
[else]
[cs-if-1 conditions=”post-type” operator=”equals” compare-value=”post”]
Post Type is Post
[else-1]
Post type is not Article or Post.
[/cs-if-1]
[/cs-if]
Supported Conditions
- [cs-if conditions=”is-logged-in”] (supported operators: equals) – User logged in
- [cs-if conditions=”ip”] (supported operators: equals) – User’s IP
- [cs-if conditions=”first-name”] (supported operators: equals, exists, not-exists) – User’s first name
- [cs-if conditions=”last-name”] (supported operators: equals, exists, not-exists) – User’s last name.
- [cs-if conditions=”display-name”] (supported operators: equals, exists, not-exists) – User’s display name.
- [cs-if conditions=”user-id”] (supported operators: equals) – User’s ID.
- [cs-if conditions=”post-id”] (supported operators: equals) – Post ID of current post in loop.
- [cs-if conditions=”post-slug”] (supported operators: equals) – Slug of current post in loop.
- [cs-if conditions=”post-type”] (supported operators: equals) – Post type of current post in loop.
To suggest new conditions, email me at: email@yeken.uk
Coming Soon
- Support for ELSE IF statements
- OR statements
- New conditions (please email suggestions email@yeken.uk)