Complianz GDPR Shortcodes

Below, you’ll find a detailed guide on how to add the Complianz – GDPR/CCPA Cookie Consent Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Complianz – GDPR/CCPA Cookie Consent Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Complianz – GDPR/CCPA Cookie Consent Plugin and the shortcodes it provides:

Plugin Icon
Complianz – GDPR/CCPA Cookie Consent

"Complianz – GDPR/CCPA Cookie Consent is a powerful WordPress plugin designed to help your website achieve GDPR/CCPA compliance with ease. It handles user consents and cookie management efficiently."

★★★★☆ (1164) Active Installs: 700000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [cmplz-dnsmpi-request]
  • [cmplz-cookies]

Complianz [cmplz-dnsmpi-request] Shortcode

The Complianz GDPR shortcode creates a data request form for users. It allows users to input their name, email, and choose from various data request options.

Shortcode: [cmplz-dnsmpi-request]

Examples and Usage

Basic example – A simple usage of the cmplz-dnsmpi-request shortcode. This will display the data request form on your webpage.

[cmplz-dnsmpi-request /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'cmplz-dnsmpi-request', array($this, 'datarequest_form') );

Shortcode PHP function:

function datarequest_form() {
			ob_start();
			?>
			<div class="cmplz-datarequest cmplz-alert">
				<span class="cmplz-close">&times;</span>
				<span id="cmplz-message"></span>
			</div>
			<form id="cmplz-datarequest-form">
				<input type="hidden" required value="us" name="cmplz_datarequest_region" id="cmplz_datarequest_region">

				<label for="cmplz_datarequest_firstname" class="cmplz-first-name"><?php echo __('Name','complianz-gdpr')?><input type="search" class="dnsmpd-firstname" value="" placeholder="your first name" id="cmplz_datarequest_firstname" name="cmplz_datarequest_firstname"></label>
				<div>
					<label for="cmplz_datarequest_name"><?php echo __('Name','complianz-gdpr')?></label>
					<input type="text" required value="" placeholder="<?php echo __('Your name','complianz-gdpr')?>" id="cmplz_datarequest_name" name="cmplz_datarequest_name">
				</div>
				<div>
					<label for="cmplz_datarequest_email"><?php echo __('Email','complianz-gdpr')?></label>
					<input type="email" required value="" placeholder="<?php echo __('email@email.com','complianz-gdpr')?>" id="cmplz_datarequest_email" name="cmplz_datarequest_email">
				</div>

				<?php
				$options = $this->datarequest_options();
				foreach ( $options as $id => $label ) { ?>
					<div class="cmplz_datarequest cmplz_datarequest_<?php echo $id?>">
						<label for="cmplz_datarequest_<?php echo esc_attr($id)?>">
							<input type="checkbox" value="1" name="cmplz_datarequest_<?php echo esc_attr($id)?>" id="cmplz_datarequest_<?php echo esc_attr($id)?>"/>
							<?php echo esc_html($label['long'])?>
						</label>
					</div>
				<?php } ?>
				<input type="button" id="cmplz-datarequest-submit" name="cmplz-datarequest-submit" value="<?php echo __('Send','complianz-gdpr')?>">
			</form>

			<style>
				/* first-name is honeypot */
				.cmplz-first-name {
					position: absolute !important;
					left: -5000px !important;
				}
			</style>
			<?php
			return ob_get_clean();
		}

Code file location:

complianz-gdpr/complianz-gdpr/DNSMPD/class-DNSMPD.php

Complianz [cmplz-cookies] Shortcode

The Complianz-GDPR shortcode is a PHP function that displays the cookies used on a website. This shortcode collects and presents cookie data, enhancing transparency for site users. It initiates the ‘cmplz_used_cookies()’ function, which gathers the cookie information, and then displays it on the site.

Shortcode: [cmplz-cookies]

Examples and Usage

Basic example – Displays the cookies used by the website using the cmplz-cookies shortcode.

[cmplz-cookies /]

Advanced examples

Although the ‘cmplz-cookies’ shortcode does not directly accept parameters, you can manipulate the output by hooking into the ‘cmplz_used_cookies’ function in your theme’s functions.php file. Here’s an example of how you might do this:


add_filter('cmplz_used_cookies', 'modify_cmplz_cookies');
function modify_cmplz_cookies($cookies){
    // Modify $cookies array as needed
    return $cookies;
}

In this advanced example, the ‘modify_cmplz_cookies’ function is hooked into ‘cmplz_used_cookies’ to modify the array of cookies before it is output by the shortcode. This allows for advanced customization of the cookies information displayed by the shortcode.

PHP Function Code

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

Shortcode line:

add_shortcode( 'cmplz-cookies', array( $this, 'cookies' ) );

Shortcode PHP function:

function cookies( $atts = array(), $content = null, $tag = '' ) {
			ob_start();
			echo cmplz_used_cookies();
			return ob_get_clean();
		}

Code file location:

complianz-gdpr/complianz-gdpr/class-document.php

Conclusion

Now that you’ve learned how to embed the Complianz – GDPR/CCPA Cookie Consent Plugin shortcodes, 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 *