Visual Form Builder Shortcode

Below, you’ll find a detailed guide on how to add the Visual Form Builder Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Visual Form Builder Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Visual Form Builder Plugin and the shortcodes it provides:

Plugin Icon
Visual Form Builder

"Visual Form Builder is a user-friendly WordPress plugin that simplifies the creation of forms. It offers effortless drag-and-drop interface, making form building a breeze. No coding skills required!"

★★★★✩ (315) Active Installs: 40000+ Tested with: 6.0.6 PHP Version: false
Included Shortcodes:
  • [vfb]

Visual Form Builder [vfb] Shortcode

The Visual Form Builder shortcode is a powerful tool that generates a customizable form on your WordPress site. It enqueues necessary scripts, sets up form attributes, and loops through each field to build a comprehensive form. It supports various field types like text, email, URL, select, radio, checkbox, address, date, time, HTML, file-upload, instructions, and submit. It also includes a spam protection feature.

Shortcode: [vfb]

Parameters

Here is a list of all possible vfb shortcode parameters and attributes:

  • id – Unique identifier of the visual form builder form.

Examples and Usage

Basic example – Display a form using its ID

[vfb id=1 /]

Advanced examples

Display a form using its ID and customize the output by enqueuing additional scripts.


function enqueue_my_scripts() {
    wp_enqueue_script( 'my-custom-script', plugins_url( '/js/my-custom-script.js', __FILE__ ) );
}
add_action( 'wp_enqueue_scripts', 'enqueue_my_scripts' );

add_shortcode( 'vfb_custom', 'display_custom_form' );
function display_custom_form( $atts, $output = '' ) {
    $atts = shortcode_atts(
        array(
            'id' => '',
        ),
        $atts,
        'vfb'
    );

    $form_id = absint( $atts['id'] );

    wp_enqueue_script( 'my-custom-script' );

    return do_shortcode( '[vfb id="' . $form_id . '"]' );
}

In the above example, we create a new shortcode [vfb_custom] that enqueues a custom script and then calls the original [vfb] shortcode to display the form. This way, we can add custom functionality to the form without modifying the original shortcode.

PHP Function Code

In case you have difficulties debugging what causing issues with [vfb] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'vfb', array( self::$instance, 'display' ) );

Shortcode PHP function:

Code file location:

visual-form-builder/visual-form-builder/public/class-form-display.php

Conclusion

Now that you’ve learned how to embed the Visual Form Builder Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *