Userfeedback Lite Shortcode

Below, you’ll find a detailed guide on how to add the Userfeedback Lite 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 Userfeedback Lite Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Userfeedback Lite Plugin and the shortcodes it provides:

Plugin Icon
User Feedback – Create Interactive Feedback Form, User Surveys, and Polls in Seconds

"User Feedback – Create Interactive Feedback Form, User Surveys, and Polls in Seconds is an efficient plugin that empowers you to quickly generate interactive user surveys, feedback forms, and polls on your WordPress site."

★★★★☆ (66) Active Installs: 100000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [handle_survey_shortcode]

Userfeedback Lite [handle_survey_shortcode] Shortcode

The Userfeedback-lite plugin shortcode is designed to handle survey shortcodes. It checks if an ‘id’ attribute exists and sanitizes it using the esc_attr function. This shortcode then returns a div container with a class of ‘userfeedback-survey-container’ and a data-id that matches the ‘id’ attribute.

Shortcode: [handle_survey_shortcode]

Parameters

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

  • id – Unique identifier for the specific survey form.

Examples and Usage

Basic example – A basic usage of the userfeedback-lite plugin shortcode is to display a specific survey by referencing its ID. This is done by inserting the shortcode into your post or page, and replacing ‘1’ with the actual ID of your survey.

[userfeedback-survey id=1 /]

PHP Function Code

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

Shortcode line:

add_shortcode( self::$USERFEEDBACK_SURVEY_SHORTCODE, array( $this, 'handle_survey_shortcode' ) );

Shortcode PHP function:

function handle_survey_shortcode( $attrs ) {
		if ( ! isset( $attrs['id'] ) ) {
			return '';
		}
		$survey_id = esc_attr($attrs['id']);
		return "<div class='userfeedback-survey-container' data-id='{$survey_id}'></div>";
	}

Code file location:

userfeedback-lite/userfeedback-lite/includes/admin/class-userfeedback-shortcodes.php

Conclusion

Now that you’ve learned how to embed the Userfeedback Lite 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 *