1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Customize QR code styling.
  5. Since


Filters the content of the QR code file. This is the raw content of the file and is useful if the file format of the QR code is SVG.

Note: This filter is only available if generating QR code. Filtering the contents of barcodes is not supported at this time. Please reach out if this is something you need!


Filter generated QR code file contents for all forms.

add_filter( 'gpqr_file_content', 'my_custom_function' );

Filter generated QR code file contents for a specific form.

add_filter( 'gpqr_file_content_FORMID', 'my_custom_function' );


  • content string

    File content represented as a UTF-8 string.

  • fg_hex string

    RGB hex to use for the foreground. Defaults to black.

  • bg_hex string

    RGB hex to use for the background. Defaults to white.

  • meta array

    Various meta information used to generate the QR code. Includes properties such as ‘error_correction_level’, ‘size’, ‘format’, and ‘form’.


Customize QR code styling.

Update QR codes to have rounded blocks and place a small logo in the center. Note, you will need to also use gpqr_params_pre_generate to generate QR codes as SVGs instead of PNGs.

To encode your image as base64, there are a variety of online solutions as well as ways to do it using CLI tools.

add_filter( 'gpqr_params_pre_generate', function ( $params, $content ) {
	$params['format'] = 'svg';

        // Increase error correction level to get more reliable scans with a logo present.
	$params['error_correction_level'] = 'q';

	return $params;
}, 10, 2 );

add_filter( 'gpqr_file_content', function ( $content, $fg_hex, $bg_hex, $meta ) {
	if ( rgar( $meta, 'format' ) === 'svg' ) {
		// Overlay a logo on the QR code.
		$logo = '<image 

		$content = str_replace( '</svg>', $logo . '</svg>', $content );

		// Round the corners of each block in the QR code.
		$content = str_replace(
			'<rect id="r0" width="6" height="6" fill="' . $fg_hex . '"/>',
			'<rect id="r0" width="5.5" height="5.5" rx="5" ry="5" fill="' . $fg_hex . '"/>',

	return $content;
}, 10, 4 );

Example output when using this snippet (converted back to PNG):

Gravity Forms QR SVG Customization Example


This filter is available since Gravity Forms QR Code 1.0.5.