php – Generate a QR code when creating a new WordPress user


I know that you can use the show_user_profile, edit_user_profile, personal_options_update and edit_user_profile_update to add and manage additional fields in user profiles.

In a site I’m developing, I need to add a new field in user profiles to store a QR code that unambiguously identifies a user when creating it. My question is, is there an easy way to generate a QR code when adding a new user to a WordPress site? If so, how? Do I need any external lib or something? Any suggestions?

function save_qrcode_user_profile_field( $user_id ) {
    if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update-user_' . $user_id ) ) {

    if ( !current_user_can( 'edit_user', $user_id ) ) { 
        return false; 

    // Here I need to generate a QR code that represents this user

    update_user_meta( $user_id, 'qrcode', $generated_qrcode );
add_action( 'personal_options_update', 'save_qrcode_user_profile_field' );
add_action( 'edit_user_profile_update', 'save_qrcode_user_profile_field' );

Any help would be appreciated.

Thanks in advance

leemon 1 year 2022-01-27T16:23:27-05:00 0 Answers 0 views 0

Leave an answer