Title: PHP inside shortcodes
Last modified: August 21, 2016

---

# PHP inside shortcodes

 *  Resolved [Nam_n](https://wordpress.org/support/users/nameez/)
 * (@nameez)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/php-inside-shortcodes/)
 * Hi,
 * I’d like check if a session variable is set before showing whats inside content
   using this plugin.
    But not sure how to add php conditions inside the short code.
 * Any instructions on how to this?
 * Thanks
 * [https://wordpress.org/plugins/shortcodes-ui/](https://wordpress.org/plugins/shortcodes-ui/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [Nam_n](https://wordpress.org/support/users/nameez/)
 * (@nameez)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/php-inside-shortcodes/#post-5083589)
 * Anyone? 🙂
 *  [GenealogyCoach](https://wordpress.org/support/users/samatva/)
 * (@samatva)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/php-inside-shortcodes/#post-5083710)
 * Hi Nam_n,
 *  As far as I know, WordPress runs with sessions “on” for logged-in users, but
   does not start sessions for all visitors. If you are having them log in, then
   a plugin such as the “Groups” plugin would be a much more secure option.
 *  I am sure there is a way to start sessions from within a plug in, but that is
   a technical answer far beyond how to use this plugin…. If the pluin runs before
   any content is put out, then it should work fine.
 *  If there is some other function that starts a session, you should be able to
   examine the session variables in the PHP part of this plugin, since session variables
   are global.
 *  Plugin Author [Bainternet](https://wordpress.org/support/users/bainternet/)
 * (@bainternet)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/php-inside-shortcodes/#post-5083747)
 * You can try somehitng like this, set the shortcode type to advanced, in the php
   setion of the shortcode paste this:
 *     ```
       if (session_status() != PHP_SESSION_NONE && isset($_SESSION['your_var'])) {
           return $content;
       }
       ```
   
 * and check the “my shortcode returns the value”.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP inside shortcodes’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/shortcodes-ui_dbeef6.svg)
 * [ShortCodes UI](https://wordpress.org/plugins/shortcodes-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ui/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Bainternet](https://wordpress.org/support/users/bainternet/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/php-inside-shortcodes/#post-5083747)
 * Status: resolved