Title: Getting the right form using do_shortcode();
Last modified: September 27, 2017

---

# Getting the right form using do_shortcode();

 *  Resolved [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/getting-the-right-form-using-do_shortcode-2/)
 * Hello!
 * I’m just looking for a solution for WordPress polylang and CF7 outputing a form
   in the template via do_shortcode(); because there is a lot of pages to insert.
   Other wise I’d insert the shortcode to each page in each language.
 * So I found the pinned topic. But it seems this plugin is useless (I’m really 
   sorry for my opinion, author). Maybe you tell why the plugin is better than the
   next construction:
 *     ```
       <?php
       $languages = pll_the_languages(array('raw' => 1));
       foreach ($languages as $language) { ?>
       <?php if ($language['slug'] == "en") { ?>
       <?php echo do_shortcode("[contact-form-7 id=\"1\"]"); ?>
       <?php }else if($language['slug'] == "ru"){ ?>
       <?php echo do_shortcode("[contact-form-7 id=\"2\"]"); ?>
       <?php } ?>
       <?php } ?>
       ```
   
 * I hope you’ll understand what I mean.
    Thanks.

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

 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/getting-the-right-form-using-do_shortcode-2/#post-9536158)
 * > this plugin is useless
 * why would 3000+ active live sites use this plugin if it was useless?
 * Did you debug your code to see what is the output result of your php snippet?
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/getting-the-right-form-using-do_shortcode-2/#post-9536398)
 * My friend, don’t offend.
    I’m sorry, I was in a hurry, so I missed the if statement.
 * Here is a working code:
 *     ```
       <?php 
       // Getting all langs
       $languages = pll_the_languages(array('raw' => 1));
       // Looping
       foreach ($languages as $language) {
       	// check if is current one
       	if ($language['current_lang'] == true) {
       		// check it slug
       		if ($language['slug'] == "ua") {
       			// this is ua? Ok, let's show UA contact form
       			echo do_shortcode("[contact-form-7 id=\"412\"]");
       		}else if($language['slug'] == "ru"){
       			// or maybe it's russian? Ok, let's show RU contact form
       			echo do_shortcode("[contact-form-7 id=\"4\"]");
       		}else{
       			// nope? Let's show the English one, it's international language anyway :)
       			echo do_shortcode("[contact-form-7 id=\"330\"]");
       		}
       	}
       }
       ?>
       ```
   
 * There are more than 3 000 websites based on WP that installed by begginers that
   even don’t know the php. So this number is not great. Checkout All In One SEO
   Pack or Yoast SEO, Contact form or WP polylang.
 * No offence, I’m just asking is there any profit to use this plugin, because there
   is no any explanation how to use it in template. Ok, you’ve made a great video
   of using ADMIN section and how to create new forms as posts. But I didn’t see
   the template work etc.
 * If it works the same way and I need to set form ID for each language – there 
   is no need for this plugin (for me).
 * Note: there are always a customer for ANY good and if someone is not your customer–
   it’s not meaning that this is a bad product. I’m JUST asking.
    -  This reply was modified 8 years, 6 months ago by [Nikita_Sp](https://wordpress.org/support/users/nikitasp/).
      Reason: clear php code
    -  This reply was modified 8 years, 6 months ago by [Nikita_Sp](https://wordpress.org/support/users/nikitasp/).
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/getting-the-right-form-using-do_shortcode-2/#post-9536469)
 * > No offence, I’m just asking is there any profit to use this plugin
 * none taken, but if you wish to get free support (as in free beer) then the best
   approach is to remain polite and not tell authors their plugin is useless. If
   you pay for the plugin then you can complain as much as you want.
 * Now, if I understand you want to automatically set the corresponding form translation
   ID and build the shortcode dynamically. For this you need to read up about polylang
   and how it stores translations.
 * Then you need to set up only 1 template with your default language form id, and
   detect which language is being requested so that you can get the translated form
   id from polylang to setup your shortcode correctly.
 * I hope that is clear.
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/getting-the-right-form-using-do_shortcode-2/#post-9536553)
 * I was just asking, because there is no info and also I already apologized in 
   first post.
 * As I understand from your post you mean that with your plugin I can just set 
   form ID on any lang and it will output correct form depending the current language,
   right?
    Or it just helping to connect forms to groups for language?
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/getting-the-right-form-using-do_shortcode-2/#post-9536823)
 * >  I can just set form ID on any lang and it will output correct form
 * yes, as long as the form ID is the translation ID from polylang
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/getting-the-right-form-using-do_shortcode-2/#post-9538600)
 * Nice, thanks.

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

The topic ‘Getting the right form using do_shortcode();’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/cf7-polylang.svg)
 * [Contact Form 7 Polylang Module](https://wordpress.org/plugins/cf7-polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-polylang/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/getting-the-right-form-using-do_shortcode-2/#post-9538600)
 * Status: resolved