Title: Using shortcode in forminator
Last modified: January 27, 2020

---

# Using shortcode in forminator

 *  Resolved [joshvic1](https://wordpress.org/support/users/joshvic1/)
 * (@joshvic1)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/)
 * Hi, I’m using forminator for my website.
 * I run a site where I give points to users using mycred.
 * I created an html field in my forminator form where I input [mycred_my_balance]
   so I can get the current user total points.
 * But it seems the shortcode is not working, it’s just showing plain like that
 * Can you help me

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

 *  Plugin Support [Imran – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support9/)
 * (@wpmudev-support9)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12368168)
 * Hello [@joshvic1](https://wordpress.org/support/users/joshvic1/)
 * I trust you’re doing well!
 * An HTML field will not render the code that a shortcode generates. Out of the
   box it is not possible to use a shortcode inside the Forminator form.
 * It can be done with some PHP coding. Please add this line inside your child theme’s
   functions.php file or use it as an [mu-plugin](https://wordpress.org/support/article/must-use-plugins/):
   `
   add_filter( 'forminator_replace_variables', 'do_shortcode' );`
 * If you do not have a child theme, please see [here](https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/)
   how to create it.
 * To add it as an mu-plugin, create a file named `forminator-render-shotycodes.
   php`, add these lines inside:
 *     ```
       <?php
       add_filter( 'forminator_replace_variables', 'do_shortcode' );
       ```
   
 * Upload this file to `/wp-content/mu-plugins/` folder. If the `mu-plugins` folder
   doesn’t exist, please feel free to create it.
 * Let us know how it went!
 * Cheers,
    Nastia
 *  Thread Starter [joshvic1](https://wordpress.org/support/users/joshvic1/)
 * (@joshvic1)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12387166)
 * Hi thanks
 * It worked but the problem is it was only displayed at the frontend
 * The number if points collected was not submitted at backend,though other details
   were submitted.
 *  Plugin Support [Dimitris – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support6/)
 * (@wpmudev-support6)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12390205)
 * Hello there [@joshvic1](https://wordpress.org/support/users/joshvic1/)
 * HTML fields aren’t included in submissions, only in emails.
 * I’ve already pinged our devs about it, so they can provide some more insights
   about it and possibly a hotfix. 🙂
 * Thank you,
    Dimitris
 *  Plugin Support [Dimitris – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support6/)
 * (@wpmudev-support6)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12413575)
 * Hello [@joshvic1](https://wordpress.org/support/users/joshvic1/)
 * Please create a new MU plugin file and insert the following code in there:
 *     ```
       <?php
       // Render shortcode on HTML fields
       add_filter( 'forminator_replace_variables', 'do_shortcode' );
       // Include shortcode output to hidden field
       add_filter( 'forminator_custom_form_submit_field_data', function( $field_data_array ){
   
           $form = array(
               'field' => 'hidden-1', // Form hidden field
               'shortcode' => '[mycred_my_balance]' // Shortcode to be rendered
           );
   
           foreach( $field_data_array as &$field_single ){
               if( $field_single['name'] === $form['field'] ){
                   $field_single['value'] = strip_tags( do_shortcode( $form['shortcode'] ) );
               }
           }
   
           return $field_data_array;
   
       });
       ```
   
 * How to: [https://premium.wpmudev.org/docs/getting-started/download-wpmu-dev-plugins-themes/#installing-mu-plugins](https://premium.wpmudev.org/docs/getting-started/download-wpmu-dev-plugins-themes/#installing-mu-plugins)
 * Then include a **Hidden field** in your form and before saving data, the above
   code will replace its value with the content of the shortcode.
 * Warm regards,
    Dimitris
 *  Thread Starter [joshvic1](https://wordpress.org/support/users/joshvic1/)
 * (@joshvic1)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12413921)
 * Thanks a lot
 * Also, is their a way the mycred balance can be automatically deducted once the
   form is submitted.
 *  Plugin Support [Imran – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support9/)
 * (@wpmudev-support9)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12416889)
 * Hello [@joshvic1](https://wordpress.org/support/users/joshvic1/)
 * I hope you are doing well!
 * This will require integration between the MyCred plugin and Forminator. Out of
   the box, it is not possible and can be achieved with custom coding.
 * I’ve forwarded your question to our developers so they could provide some feedback.
   We will follow back in here once there will be an update.
 * Have a good day!
 * Cheers,
    Nastia
 *  Thread Starter [joshvic1](https://wordpress.org/support/users/joshvic1/)
 * (@joshvic1)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12416928)
 * Sorry for my too much questions
 * Lastly, I noticed the code you gave me is only possible with hidden fields.
 * In a case where I need to use different shortcodes on different forms. How do
   I make that possible.
 * For instance now..i have a form named (mycred form), let’s say that code works
   for that.
 * I also have another form named (affiliate form) and I want to show one of the
   affiliate earnings on it also with this shortcode [affiliate_earnings status=”
   unpaid”]
 * How do I get that done
 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12434239)
 * Hi [@joshvic1](https://wordpress.org/support/users/joshvic1/)
 * I hope you’re well today!
 * If you only want to show/render shortcode output on front-end (e.g to show affiliate
   earnings) the solution that [@wpmudev-support9](https://wordpress.org/support/users/wpmudev-support9/)
   shared earlier here
 * [https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12368168](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12368168)
 * will also work.
 * You will just want to add a “HTML” field instead of a “Hidden” field to the form
   and put your shortcode into it (preferably through “Text” mode of editor).
 * Best regards,
    Adam
 *  Plugin Support [Imran – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support9/)
 * (@wpmudev-support9)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12554023)
 * Hello [@joshvic1](https://wordpress.org/support/users/joshvic1/)
 * I hope you are doing well!
 * We haven’t heard back from you for a while now so we’ve marked this ticket as
   resolved. If you do have any followup questions or require further assistance
   feel free to reopen it and let us know here.
 * Kind regards,
    Nastia
 *  [cory61574](https://wordpress.org/support/users/cory61574/)
 * (@cory61574)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12695454)
 * I have the same issue – Trying to pass shortcode into hidden field in the forminator
   form. Tried adding the add_filter( ‘forminator_replace_variables’, ‘do_shortcode’);
   to the function file. and it did not work.
 * We are not using MU plugin.
 * See screenshot here: [https://www.dropbox.com/s/58gp63a4glfptcw/2020-04-18_17-31-53.jpg?dl=0](https://www.dropbox.com/s/58gp63a4glfptcw/2020-04-18_17-31-53.jpg?dl=0)
 * Cory
 *  Plugin Support [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * (@wpmudev-support2)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12719085)
 * Hello [@cory61574](https://wordpress.org/support/users/cory61574/) ,
 * The code you are using is only for the HTML field. If you want to use hidden 
   fields, you need to use code provided here [https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12413575](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12413575)
 * kind regards,
    Kasia
 *  [ckgrafico](https://wordpress.org/support/users/ckgrafico/)
 * (@ckgrafico)
 * [6 years ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12879974)
 * Is this only working for html field?
    I’m not able to use a shortcode in a label
   only in html field
 * > [View post on imgur.com](https://imgur.com/sstXgCj)
 *  [ckgrafico](https://wordpress.org/support/users/ckgrafico/)
 * (@ckgrafico)
 * [6 years ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12881666)
 * Was not easy but I think I did it 🙂 if someone elsee needs the code
 *     ```
       function forminator_callback($html) {
       	// WordPress does not like to use shortcodes in html attributes
       	preg_match_all('|(="\[.*\])(.*)(\[\/.*\])|U', $html, $matches);
       	$codes = $matches[0];
   
       	if (!$codes) {
       		return do_shortcode($html);
       	}
   
       	foreach ($codes as $code) {
       		$html = str_replace($code, do_shortcode($code), $html);
       	}
   
       	return do_shortcode($html);
       }
       add_filter( 'forminator_render_fields_markup', 'forminator_callback' );
       ```
   
 *  [briansuttongv](https://wordpress.org/support/users/briansuttongv/)
 * (@briansuttongv)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-13133397)
 * I have implemented the MU plugin to use this in an HTML field. I’d like to use
   multiple shortcodes from custom user fields as items in a dropdown select in 
   Forminator. Is this possible?
 * [@wpmudev-support2](https://wordpress.org/support/users/wpmudev-support2/) [@wpmudev-support9](https://wordpress.org/support/users/wpmudev-support9/)
   [@wpmudev-support8](https://wordpress.org/support/users/wpmudev-support8/) [@wpmudev-support6](https://wordpress.org/support/users/wpmudev-support6/)
 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-13144610)
 * Hi [@briansuttongv](https://wordpress.org/support/users/briansuttongv/)
 * I hope you’re well today!
 * I’m not sure which of the codes mentioned in this thread have you implemented
   but the one shared above by [@ckgrafico](https://wordpress.org/support/users/ckgrafico/)
   should actually allow shortcodes in all fields where you can only add them. Have
   you tried it already?
 * [https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12881666](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-12881666)
 * If it doesn’t work and/or you need any further assistance with this, please start
   a new thread of your own (as per [this forum’s guidelines](https://wordpress.org/support/forum-user-guide/faq/#i-have-the-same-problem-can-i-just-reply-to-someone-elses-post-with-me-too))
   and I and my colleagues we’ll be happy to work on this with you.
 * Best regards,
    Adam

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

The topic ‘Using shortcode in forminator’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 15 replies
 * 8 participants
 * Last reply from: [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/using-shortcode-in-forminator/#post-13144610)
 * Status: resolved