openid-connect-generic icon indicating copy to clipboard operation
openid-connect-generic copied to clipboard

Syncing user data fields between Wordpress and OIDC server (Keycloak)

Open binaryfire opened this issue 5 years ago • 4 comments

Hi, just wondering if there's any way to sync user data (custom fields) between Wordpress and Keycloak? If so, could someone point me in the right direction? Thanks!

binaryfire avatar Apr 27 '19 18:04 binaryfire

From keycloak to wordpress can be done via hooks, for revese, I'm researching as well

bevinhex avatar Oct 24 '19 10:10 bevinhex

@bevinhex Is there documentation on how to do that with hooks?

alerque avatar May 27 '21 19:05 alerque

@alerque I don't think there is documentation atm, but I could write up something simple. Currently working on another plugin that will provide a UI for this, but it's probably a few weeks out.

here is a very rough draft to get you started

<?php


add_action( 'openid-connect-generic-user-logged-in', 'my_oidc_user_login' );

function my_oidc_user_login( \WP_User $user ) {
	// Everything we know about the user from the IDP.
	$id_token_claim = get_user_meta( $user->ID, 'openid-connect-generic-last-id-token-claim', true );
	$subject_identity = get_user_meta( $user->ID, 'openid-connect-generic-subject-identity', true );
	$user_claim = get_user_meta( $user->ID, 'openid-connect-generic-last-user-claim', true );
	$token_response = get_user_meta( $user->ID, 'openid-connect-generic-last-token-response', true );

	// Do something w/ it here...
}

daggerhart avatar May 27 '21 20:05 daggerhart

Hello @daggerhart Sent you an email from your contact form. Just checking to see if you received it

jmayermsi avatar Oct 22 '21 15:10 jmayermsi