Generate User ID QR Code for New Users

Code

Filename: gpqr-new-user-qr-meta.php

<?php
/**
 * Gravity Perks // QR Codes // Generate User ID QR Code for New Users
 * https://gravitywiz.com/documentation/gravity-forms-qr-code/
 */
// Update "user_register" to "gform_user_registered" to limit QR generation only to users created via a Gravity Form.
add_action( 'user_register', function( $user_id ) {
	if ( is_callable( 'gp_qr_code' ) ) {
		add_user_meta( $user_id, 'qr_code', gp_qr_code()->generator->generate( (string) $user_id ) );
	}
} );

Leave a Reply

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

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.