Title: Logical values
Last modified: December 4, 2023

---

# Logical values

 *  [chelminski](https://wordpress.org/support/users/chelminski/)
 * (@chelminski)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/logical-values/)
 * Possibility to use logical values. For example:
 * __________________
 * If the returned value (from another query) is greater than -1, show X
 * **[sv slug=”logic” rule=”>-1″ true=”X” false=”Illegal value”]**[sv slug=”sc-db-
   value-by-id” table=”money_balance” column=”value” column-to-search=”name” key
   =”chelminski” key-format=”%d” message-not-found=”none”]**[/sv slug=”logic”]**
 * __________________
 * If the returned value (from another query) equals “moderator” then show X
 * **[sv slug=”logic” rule=”equal=moderator” true=”X” false=”Y”]**[sv slug=”sc-db-
   value-by-id” table=”perms_primary_group” column=”group” column-to-search=”name”
   key=”chelminski” key-format=”%s” message-not-found=”none”]**[/sv slug=”logic”]**
 * __________________
 * If the returned value (from another query) starts with “goo” then show X
 * **[sv slug=”logic” rule=”start=goo” true=”X” false=”Y”]**[another sample shortcode]**[/
   sv slug=”logic”]**
 * __________________
 * If the returned value (from another query) endswith “gle” then show X
 * **[sv slug=”logic” rule=”end=gle” true=”X” false=”Y”]**[another sample shortcode]**[/
   sv slug=”logic”]**
 * Where in the future I would like it to be possible, for example, to insert another
   shortcode in addition to plain text instead of X.
 * If possible then logical values a bit like in Excel with support for shortcodes
   stuffed everywhere 😅😅 E.g.
 * check if [shortcode]=”test” then show “text”, if not then:
   check if [shortcode]
   =”admin” then show “text”, if not then:check if [shortcode]=”moderator” then 
   show “text”, if not then:check if [shortcode]=”beta_tester” then show “text”,
   if not then:check if [shortcode]=”user” then show “text”, if not then:show “LOG
   IN!”
 * In the future, it can be expanded with many other elements, such as:
    - Whether it contains text
    - Does it have the right number of letters?
    - Value comparison, whether one value equals another (e.g. 2 shortcodes)
      Others
      that don’t come to mind right now
 * Would it be possible to implement something like this?

Viewing 1 replies (of 1 total)

 *  Plugin Author [YeKen](https://wordpress.org/support/users/aliakro/)
 * (@aliakro)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/logical-values/#post-17256445)
 * Ah funny you say that, I have been thinking of adding something like this. I 
   do currently have this in my Weight Tracker plugin (well, to a more limited degree):
 * [https://docs.yeken.uk/shortcodes/wt-if.html](https://docs.yeken.uk/shortcodes/wt-if.html)

Viewing 1 replies (of 1 total)

The topic ‘Logical values’ is closed to new replies.

 * ![](https://ps.w.org/shortcode-variables/assets/icon-256x256.png?rev=2402961)
 * [Snippet Shortcodes](https://wordpress.org/plugins/shortcode-variables/)
 * [Support Threads](https://wordpress.org/support/plugin/shortcode-variables/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcode-variables/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcode-variables/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcode-variables/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [YeKen](https://wordpress.org/support/users/aliakro/)
 * Last activity: [2 years, 5 months ago](https://wordpress.org/support/topic/logical-values/#post-17256445)
 * Status: not resolved