Support » Plugin: Zoho CRM Lead Magnet » Zoho CRM Forms Shortcode

  • Resolved Rotozaza

    (@rotozaza)


    After playing around we recommend Zoho Forms, which seems to be strageic future of how to use an build forms with CRM – way cool.

    We checked different approaches and came up with this Query and Shortcode:

    Define what can overwrite the shortcode.

    // Query
    
    function companyname_add_query_vars( $vars ) {
      array_push($vars, "id", "partner", "owner", "redirect");
      return $vars;
    }
    add_filter( 'query_vars', 'companyname_add_query_vars' );

    Define what will be passed from shortcode to form

    // Shortcodes 
    
    function companyname_zoho_form_shortcode($atts)
    {
        // normalize attribute keys, lowercase
        $atts = array_change_key_case((array)$atts, CASE_LOWER);
    
        // override default attributes with user attributes
        $companyname_atts = shortcode_atts([
               'url' => '', 
               'source' => 'Websites', 
               'class' => 'zohoform',
               'id' => get_query_var('id', 'zohoform'), 
    					 'redirect' => get_query_var('redirect', ''),
               'owner' => get_query_var('owner', 'Abstract of Default Username'), 
               'partner' => get_query_var('partner', 'Default Referal Partner'), 
           ], $atts, 'companynamezohoform');
     
        // start output
    
    		$url = esc_html__($companyname_atts['url'], 'companyname').'?partner='.esc_html__(urlencode($companyname_atts['partner']), 'companyname').'&owner='.esc_html__($companyname_atts['owner'], 'companyname').'&redirect='.esc_html__($companyname_atts['redirect'], 'companyname'); 
        $o = '<iframe id="'.esc_html__($companyname_atts['id'], 'companyname').'" class="zohoform" style="width:100%;border:none;overflow:hidden;" src="'.esc_url($url).'" scrolling="no" frameborder="0">';
    
        // enclosing tags
        if (!is_null($content)) {
            // secure output by executing the_content filter hook on $content
            $o .= apply_filters('the_content', $content);
     
            // run shortcode parser recursively
            $o .= do_shortcode($content);
        }
     
        // end box
        $o .= '</iframe>';
     
        // return output
        return $o;
    }
     
    function companyname_shortcodes_init() {
        add_shortcode('companynamezohoform', 'companyname_zoho_form_shortcode');
    }
     
    add_action('init', 'companyname_shortcodes_init');

    And use this in raw HTML or Editor

    
    [companynamezohoform id="CSS added to form" partner="Referal Partner XYZ" owner="Abstract of Username" redirect="URL" url="https://forms.zohopublic.com/companyname/form/ZohoCRMB2BPartnerAnmeldung/formperma/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]
    • This topic was modified 5 months ago by Rotozaza.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.