Userswp Shortcode

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

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

Plugin Icon
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WordPress

"UsersWP is a comprehensive WordPress plugin offering front-end login forms, user registration, user profiles and a members directory. Designed to enhance user management on your site."

★★★★☆ (145) Active Installs: 10000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [userswp]

Userswp [userswp] Shortcode

The UsersWP Plugin shortcode is designed to output specific widget settings. It includes filters for customizing settings, defining classes, and applying attributes. It also handles enclosed shortcodes and previews.

Shortcode: [userswp]

Parameters

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

  • args – an array of the current widget instance’s settings.
  • content – enclosed shortcode added to the special `html` argument.
  • widget_ops['classname'] – used to set the class of the widget.
  • no_wrap – decides if the output is wrapped in a div or not.
  • title – the title of the widget or shortcode.

Examples and Usage

Basic example – A simple usage of the shortcode to output the desired widget based on its base_id.

[widget base_id="your_widget_base_id" /]

Advanced examples

Using the shortcode to output the widget with a specific title, and disabling the wrapping div by setting no_wrap to true.

[widget base_id="your_widget_base_id" title="My Custom Title" no_wrap="true" /]

Applying the shortcode to output a widget with additional HTML content enclosed within the shortcode. The enclosed content will be added to the ‘html’ argument of the widget.

[widget base_id="your_widget_base_id"]Extra HTML content goes here.[/widget]

Applying the shortcode to output a widget with a specific class name. This class name will be added to the wrapping div of the widget output.

[widget base_id="your_widget_base_id" widget_ops="{classname: 'my-custom-class'}" /]

Please note that you need to replace “your_widget_base_id” with the actual base_id of the widget you want to output.

PHP Function Code

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

Shortcode line:

add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );

Shortcode PHP function:

function shortcode_output( $args = array(), $content = '' ) {
			$_instance = $args;

			$args = $this->argument_values( $args );

			// add extra argument so we know its a output to gutenberg
			//$args
			$args = $this->string_to_bool( $args );

			// if we have a enclosed shortcode we add it to the special `html` argument
			if ( ! empty( $content ) ) {
				$args['html'] = $content;
			}

			if ( ! $this->is_preview() ) {
				/**
				 * Filters the settings for a particular widget args.
				 *
				 * @param array          $args      The current widget instance's settings.
				 * @param WP_Super_Duper $widget    The current widget settings.
				 * @param array          $_instance An array of default widget arguments.
				 *
				 *@since 1.0.28
				 *
				 */
				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );

				if ( ! is_array( $args ) ) {
					return $args;
				}
			}

			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
			$class .= " sdel-".$this->get_instance_hash();

			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );

			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );

			$shortcode_args = array();
			$output         = '';
			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
				$no_wrap = true;
			}
			$main_content = $this->output( $args, $shortcode_args, $content );
			if ( $main_content && ! $no_wrap ) {
				// wrap the shortcode in a div with the same class as the widget
				$output .= '<div class="' . $class . '" ' . $attrs . '>';
				if ( ! empty( $args['title'] ) ) {
					// if its a shortcode and there is a title try to grab the title wrappers
					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
					if ( empty( $instance ) ) {
						global $wp_registered_sidebars;
						if ( ! empty( $wp_registered_sidebars ) ) {
							foreach ( $wp_registered_sidebars as $sidebar ) {
								if ( ! empty( $sidebar['before_title'] ) ) {
									$shortcode_args['before_title'] = $sidebar['before_title'];
									$shortcode_args['after_title']  = $sidebar['after_title'];
									break;
								}
							}
						}
					}
					$output .= $this->output_title( $shortcode_args, $args );
				}
				$output .= $main_content;
				$output .= '</div>';
			} elseif ( $main_content && $no_wrap ) {
				$output .= $main_content;
			}

			// if preview show a placeholder if empty
			if ( $this->is_preview() && $output == '' ) {
				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
			}

			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
		}

Code file location:

userswp/userswp/vendor/ayecode/wp-super-duper/wp-super-duper.php

Conclusion

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