PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Make shortcode work in Dashboard widget?

  1. I have added code to include a custom dashboard widget, but it ends up a bit funny....

    add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
    
    function my_custom_dashboard_widgets() {
    global $wp_meta_boxes;
    
    wp_add_dashboard_widget('custom_help_widget', 'Get Support', 'custom_dashboard_help');
    }
    
    function custom_dashboard_help() {
    echo do_shortcode('[gravityform id="1" name="Customer Support"]');
    }

    Heres what it looks like..
    https://dl.dropbox.com/u/9832993/shortcode.png

    How can I make those edit/delete options go away?

    Posted 7 years ago on Thursday February 7, 2013 | Permalink
  2. It looks like you are not including the Gravity Forms scripts and style. Please try enqueuing them when your widget loads using gravity_form_enqueue_scripts.

    http://www.gravityhelp.com/documentation/page/Gravity_form_enqueue_scripts

    You're basically doing this (although you are using do_shortcode not the function call):
    http://www.gravityhelp.com/documentation/page/Embedding_A_Form#Function_Call

    When you include a Gravity Form like that, you have to include the scripts yourself.

    Gravity Forms was not designed to be used in the admin area, so this may not work properly even after you enqueue the scripts.

    Posted 7 years ago on Friday February 8, 2013 | Permalink