Title: Error When Using do_shortcode
Last modified: December 11, 2019

---

# Error When Using do_shortcode

 *  Resolved [TheRealMikeD](https://wordpress.org/support/users/therealmiked/)
 * (@therealmiked)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-when-trying-using-do_shortcode/)
 * Hi Everyone,
 * Very cool plug-in. It works just fine when pasting the shortcode into post content.
   But when trying to call do_shortcode() from within PHP code in the theme, I get
   the following error message:
    Notice: Undefined index: dae_settings in /(full
   path redacted)/wp-content/plugins/download-after-email/includes/shortcodes.php
   on line 334.
 * Line 334 contains the following code:
    `$dae_settings = $GLOBALS['dae_settings'][
   $download_id ];`
 * So it looks like that global variable does not get initialized prior to usage
   in this case. In addition to the error message, an incomplete version of the 
   form is displayed, which makes sense, looking at the plugin code surrounding 
   the line where the error was reported. Only the title and primary content text
   are filled in. Everything else is empty HTML elements.
 * Please let me know if this is something that I can work around or if it requires
   an update to the plugin.
 * Thanks!
    -  This topic was modified 6 years, 6 months ago by [TheRealMikeD](https://wordpress.org/support/users/therealmiked/).

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

 *  Thread Starter [TheRealMikeD](https://wordpress.org/support/users/therealmiked/)
 * (@therealmiked)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/error-when-trying-using-do_shortcode/#post-12233273)
 * So I was able to patch this issue by augmenting the problematic code as follows:
 *     ```
       if (isset($GLOBALS['dae_settings'])) {
           $dae_settings = $GLOBALS['dae_settings'][ $download_id ];
       } else {
           $dae_settings = get_post_meta( $download_id, 'dae_settings', true );
       }
       ```
   
 * With this patch, all the HTML gets output correctly when calling do_shortcode()
   from the theme’s PHP code. The inline CSS does NOT get output in this case, but
   as a theme developer, I actually like it better this way. It allows me to write
   my own CSS that will be consistent throughout the theme without having to use`!
   important` to override a lot of styles.
 *  Plugin Author [mkscripts](https://wordpress.org/support/users/mkscripts/)
 * (@mkscripts)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/error-when-trying-using-do_shortcode/#post-12236357)
 * Hi there,
 * Good to hear that you like our plug-in.
 * This is the right way to work around it, but we will adjust this behaviour with
   the next update, so this patch is no longer needed. That way it’s easier to implement
   the shortcode by using do_shortcode().
 * The CSS is indeed not loaded via the shortcode function. We will leave it this
   way so that you always have the possibility to write the CSS yourself.
 * Thanks for noticing. If you have any more questions, feel free to ask.
 * Best regards,
    Team Download After Email
 *  Thread Starter [TheRealMikeD](https://wordpress.org/support/users/therealmiked/)
 * (@therealmiked)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/error-when-trying-using-do_shortcode/#post-12236844)
 * Cool. I will leave my patch in place until you release an updated version that
   includes this fix.
 * Thanks!
 *  Plugin Author [mkscripts](https://wordpress.org/support/users/mkscripts/)
 * (@mkscripts)
 * [6 years ago](https://wordpress.org/support/topic/error-when-trying-using-do_shortcode/#post-12810944)
 * Since version 2.0.3 the CSS styling options are loaded via the do_shortcode()
   function by default. To disable the CSS styling options, you can use a new shortcode
   attribute: css=”off”.
 *  Thread Starter [TheRealMikeD](https://wordpress.org/support/users/therealmiked/)
 * (@therealmiked)
 * [6 years ago](https://wordpress.org/support/topic/error-when-trying-using-do_shortcode/#post-12816751)
 * The new attribute works well. Thanks for letting me know!

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

The topic ‘Error When Using do_shortcode’ is closed to new replies.

 * ![](https://ps.w.org/download-after-email/assets/icon-256x256.png?rev=2016027)
 * [Download After Email - Subscribe & Download Form Plugin](https://wordpress.org/plugins/download-after-email/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/download-after-email/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/download-after-email/)
 * [Active Topics](https://wordpress.org/support/plugin/download-after-email/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/download-after-email/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/download-after-email/reviews/)

## Tags

 * [do_shortcode](https://wordpress.org/support/topic-tag/do_shortcode/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 5 replies
 * 2 participants
 * Last reply from: [TheRealMikeD](https://wordpress.org/support/users/therealmiked/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/error-when-trying-using-do_shortcode/#post-12816751)
 * Status: resolved