Support » Plugin: Contact Form 7 » [Plugin: Contact Form 7] Using shortcode in admin section

  • Hi,

    Apologies if this has been answered elsewhere, I have tried searching for hours to find a solution. I want to show one of my Contact Form 7 forms in my admin section. I have created a new page with add_utlity_page, which works fine. If I hard code an HTML form (or in fact anything) into the callback function, it displays it fine. The problem comes when I try to use the contact 7 shortcode. The strange thing is, some shortcode I have tried (not CF7) seems to work (e.g. one by Twitter Tools) – but both when I try to CF7 one, and when I try to create a function and use that, it both fails. Anyone have any ideas?

    Here is the code I am using to register the page/try to echo the shortcode –

    add_action('admin_menu', 'my_plugin_statement');
    
    function my_plugin_statement() {
        global $wpdb;
    add_utility_page( 'Contact Form', 'Contact', 'subscriber', 'contact-form-123abc', 'my_plugin_options','images/tick.png' );
    }
    
    function my_plugin_options() {
    
    //menu callback function  
    
    global $wpdb;
    
      echo '<div class="wrap">';
    
    //THIS WORKS
    echo do_shortcode('[aktt_tweets count=5]');
    
    //THIS FAILS - JUST PRINTS OUT [contact-form-7 id="123"]
    echo do_shortcode('[contact-form-7 id="123" title="Contact Form 1"]');
    
    //HARD CODING THE FORM HERE WORKS
    echo'<form method="post" action="'.$_SERVER['PHP_SELF'].'"><textarea>Hello</textarea><input type="submit"></form>';
      echo '</div>';
    }

    http://wordpress.org/extend/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Contact Form 7] Using shortcode in admin section’ is closed to new replies.