• Resolved rafaviana

    (@rafaviana)


    Hi,
    I’m adding the contact form shortcode with a function on my functions.php file. The problem is that the form slider doesn’t work if I do that way, it only work if I add the shortcode into a page or widget.

    Is it possible to do it this way?

    Thanks

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    I’m adding the contact form shortcode with a function on my functions.php file.

    can you share the function and filter you are using?

    Thread Starter rafaviana

    (@rafaviana)

    Yes of course

    
    // Trigger a Modal Popup on the Click of a Menu Element
    // https://ultimate.brainstormforce.com/docs/trigger-a-modal-popup-on-the-click-of-a-menu/
    function ultimate_VC_modal_popup() {
      if (ICL_LANGUAGE_CODE == "pt-pt") {
          echo do_shortcode( '
          [ultimate_modal modal_on="custom-selector" modal_title="Localizar representante" modal_on_selector=".display-contact-popup" modal_size="small" modal_style="overlay-fade" el_class="dealer-popup" overlay_bg_opacity="80" img_size="20" close_icon_position="popup-top-right"]
          <p class="intro">De forma a podermos encontrar um representante na sua zona, preencha os campos a baixo e entraremos em contacto consigo.</p>
          [cf7form cf7key="revendedor-pt"]
          [/ultimate_modal]' );
        }
      }
    add_action('wp_footer', 'ultimate_VC_modal_popup');
    Plugin Author Aurovrata Venet

    (@aurovrata)

    the issue may be with the embedding of the cf7 shortcode within the other shortcode…

    Have you tried simply: echo do_shortcode('[cf7form cf7key="revendedor-pt"]'); ?

    Thread Starter rafaviana

    (@rafaviana)

    Hi,
    I didn’t try it but I need to have that way, because the contact form needs to be showed inside a modal box and the other shortcode is to do that

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I didn’t try it but I need to have that way,

    please try first, and let me know what you get

    Plugin Author Aurovrata Venet

    (@aurovrata)

    the other possibility which it does not work is because you might be hooking it too late on ‘wp_footer’. Does it work if you inslude the wrapping shortcode inside the page content?

    Thread Starter rafaviana

    (@rafaviana)

    It works if I use the shortcode isolated, like this:

    function ultimate_VC_modal_popup() {
          echo do_shortcode( '[cf7form cf7key="teste"]' );
      }
    add_action('wp_footer', 'ultimate_VC_modal_popup');

    But as I said I need to have the contact form inside the other shrotcode… if there’s no possibility to work like that, I will forget the idea to have the slider in the form

    Plugin Author Aurovrata Venet

    (@aurovrata)

    It works if I use the shortcode isolated, like this:

    good, so we have identified the reason.

    if there’s no possibility to work like that

    not with this approach at least for now. I may in the future look at why this does not work, but for now you need a different approach.

    use the 'do_shortcode_tag' filter introduced in v4.7 of WP,

    
    add_filter('do_shortcode_tag', 'wrap_cf7sg_form',10,3);
    function wrap_cf7sg_form($output, $tag, $attr){
      //check if this is a form shortcode.
      if('cf7form' !== $tag) return $output;
      //check if this is the right form.
      if('revendedor-pt' != $attr['cf7key'] return $output;
    
      $output = do_shortcode('
          [ultimate_modal modal_on="custom-selector" modal_title="Localizar representante" modal_on_selector=".display-contact-popup" modal_size="small" modal_style="overlay-fade" el_class="dealer-popup" overlay_bg_opacity="80" img_size="20" close_icon_position="popup-top-right"]
          <p class="intro">De forma a podermos encontrar um representante na sua zona, preencha os campos a baixo e entraremos em contacto consigo.</p>
          '.$output.'[/ultimate_modal]');
      return $output;
    }
    Thread Starter rafaviana

    (@rafaviana)

    Hi, thanks for your answer.
    When I added that code on functions file the website doesn’t work. My WordPress versions is 5.5.3

    Plugin Author Aurovrata Venet

    (@aurovrata)

    the website doesn’t work.

    did you switch on WP_DEBUG mode to see where the error is coming from?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    … there is a missing bracket in the code, try

    add_filter('do_shortcode_tag', 'wrap_cf7sg_form',10,3);
    function wrap_cf7sg_form($output, $tag, $attr){
      //check if this is a form shortcode.
      if('cf7form' !== $tag) return $output;
      //check if this is the right form.
      if('revendedor-pt' != $attr['cf7key']) return $output;
    
      $output = do_shortcode('
          [ultimate_modal modal_on="custom-selector" modal_title="Localizar representante" modal_on_selector=".display-contact-popup" modal_size="small" modal_style="overlay-fade" el_class="dealer-popup" overlay_bg_opacity="80" img_size="20" close_icon_position="popup-top-right"]
          <p class="intro">De forma a podermos encontrar um representante na sua zona, preencha os campos a baixo e entraremos em contacto consigo.</p>
          '.$output.'[/ultimate_modal]');
      return $output;
    }
    Thread Starter rafaviana

    (@rafaviana)

    Hi, it still doesn’t work, I think it’s because that code doesn’t add the shortcode into the HTML, right? I need to add it somewhere, ie, in the footer

    Plugin Author Aurovrata Venet

    (@aurovrata)

    you said,

    t works if I use the shortcode isolated, like this:

    function ultimate_VC_modal_popup() {
          echo do_shortcode( '[cf7form cf7key="revendedor-pt"]' );
      }
    add_action('wp_footer', 'ultimate_VC_modal_popup');
    

    have you tried?

    Thread Starter rafaviana

    (@rafaviana)

    I, yes I tried and it works as I said. But how can I use the code you gave:

    add_filter('do_shortcode_tag', 'wrap_cf7sg_form',10,3);
    function wrap_cf7sg_form($output, $tag, $attr){
      //check if this is a form shortcode.
      if('cf7form' !== $tag) return $output;
      //check if this is the right form.
      if('revendedor-pt' != $attr['cf7key']) return $output;
    
      $output = do_shortcode('
          [ultimate_modal modal_on="custom-selector" modal_title="Localizar representante" modal_on_selector=".display-contact-popup" modal_size="small" modal_style="overlay-fade" el_class="dealer-popup" overlay_bg_opacity="80" img_size="20" close_icon_position="popup-top-right"]
          <p class="intro">De forma a podermos encontrar um representante na sua zona, preencha os campos a baixo e entraremos em contacto consigo.</p>
          '.$output.'[/ultimate_modal]');
      return $output;
    }

    With this one:

    function ultimate_VC_modal_popup() {
          echo do_shortcode( '[cf7form cf7key="revendedor-pt"]' );
      }
    add_action('wp_footer', 'ultimate_VC_modal_popup');
    Plugin Author Aurovrata Venet

    (@aurovrata)

    you need to as both of the above codes to your functions.php file

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

The topic ‘Multi-step slider doesn’t work with shortcode’ is closed to new replies.