Support » Plugins » [Plugin: Fast and Secure Contact Form] how to call form from page template

Viewing 14 replies - 1 through 14 (of 14 total)
  • Shortcode is the recommended way, but this should work:

    <?php if ( isset($si_contact_form) ) echo $si_contact_form->si_contact_form_short_code(); ?>

    Works great! Thanks again, Mike. Great Plugin…. I like putting it into the template because it keeps it safely tucked away from uninformed “editors” and they can edit labels and text and such from the plugin’s settings anyway…

    After adding the multi-form feature there is a change calling the form with code. This is the updated code for the current version:
    Change the form number as needed.

    <?php if ( isset($si_contact_form) ) echo $si_contact_form->si_contact_form_short_code( array( 'form' => '1' ) ); ?>

    Does this feature work within the sidebar.php file? I can’t seem to get it to work.

    Do you want to be able to use a shortcode in your blog’s sidebar instead of your post or page?

    Normally, shortcodes are ignored if you try putting them in a sidebar widget — all that’s displayed is the shortcode itself. But there is a one-line tweak you can add to your theme that will enable you to put any shortcode you like in a sidebar widget. For example, one AZIndex user recently wanted to display an index generated by the plugin in his blog’s sidebar. These are the steps he followed:

    1. Login to your blog’s administration pages and go to the Theme Editor — i.e. select Appearance >> Editor from the admin menu.
    2. Look in the list of Template Files on the right of the page for one called Theme Functions or functions.php and click on it to load it into the editor.
    3. Find a place between the <?php and ?> tags which is not in the middle one of the functions that may already be in the file (the very top or bottom of the file are both good places) and add the following line:
    add_filter(‘widget_text’, ‘do_shortcode’);
    4. Click on the Update File button to save the modified template.

    That’s all you need to do. Now any shortcodes you add to a sidebar widget will be correctly processed by the plugin they belong to. The easiest way to test this is as follows:

    1. Go to Appearance >> Widgets using the administration menu.
    2. Find the Text widget in the list on the left, and click its Add button.
    3. Click on the new widget’s Edit link, and enter a title for the widget and then add the shortcode below it.
    4. Click the Change button, then click the Save Changes button (easy to forget) and then go to the front page of your blog to see your new shortcode-enabled widget.

    (Note: your theme must support widgets for the new text widget to show up. If it doesn’t then you will have to “widgetize” your theme or find another theme that does support widgets.)

    I would prefer to use the php template code, rather than a shortcode. I’ve created a homegrown template, I’ve never had much use for widgets. I can always add this support… I’ll mull it over for a few more hours before I dig in.

    Is this the best way to implement a contact for in the sidebar? With a shortcode?


    <?php if ( isset($si_contact_form) ) echo $si_contact_form->si_contact_form_short_code(); ?>

    If you need to add a form higher than 1, use this code(change 1 to the correct form number).

    <?php if ( isset($si_contact_form) ) echo $si_contact_form->si_contact_form_short_code( array( 'form' => '1' ) ); ?>

    Thanks Mike,
    I actually tried using the second version of that form code, which I found on the plugin page. Unfortunately, it doesn’t spit out any code.

    I removed the “isset” and it spits out an error message.

    You can see it here:

    Fatal error: Call to a member function si_contact_form_short_code() on a non-object in sidebar.php on line 54

    guerrilladigital is the plugin installed and activated?

    Yes sir. In fact, I originally had the contact form on that page, but I used the shortcode method via <?php the_content ?>. So yes, it installed and working.. just not within the sidebar. I wonder if it’s somehow out-of-scope?

    maybe the theme? I think others have used it and it worked before.

    It could be the theme you are using is causing it…
    Do this as a test:
    In Admin, click on Appearance, Themes.
    Temporarily change your theme to the “WordPress Default” theme.
    Does it work properly now?
    If it does then the theme you are using is the cause.

    I’m creating a theme from scratch. I’ve used other template codes (like Twitter for WordPress) in the sidebars of my sites.

    I’ve scrapped it in favor of a Tectite form.

    Hi guys.

    I edited the file page.php and added the code MikeChallis said above:

    <?php if ( isset($si_contact_form) ) echo $si_contact_form->si_contact_form_short_code( array( 'form' => '1' ) ); ?>

    It works great forthe pages I have, but I´m not having any results in posts.

    Anybody knows why is this happening??
    I added a restriction in my code, maybe I´m missing something, so this is my code:

    $id = get_the_ID();
    $restriction = array("3", "17", "29");
    if(!in_array($id, $restriction))
    	if ( isset($si_contact_form) ) echo $si_contact_form->si_contact_form_short_code( array( 'form' => '1' ) );


Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: Fast and Secure Contact Form] how to call form from page template’ is closed to new replies.