Hi there, instead of opening a new thread, I bump that one up ??
We don’t have exactly the same question but it goes in the same direction.
We have two WP websites with a Single Sign On.
Site A (the shop) / Site B (the support center)
** On site A **
Users are signing up on Site A. They get the default core WP role. UM is NOT installed on Site A.
On top of the “basic” WP role, we have two custom roles that we assigned manually (with the plugin User Role Editor).
Role “1”
Role “2”
When users click on “service center” the are redirected on Site B.
** On site B **
We created exactly the same WP core roles than on site A.
If use arrive from site A with the role 2, he has the same role on Site B.
=> Ultimate Member.
We created in UM the two roles and names them like our “core custom worpdress role”: “1” & “2”.
Now our issue:
We can synchronize with WP role in the direction UM Role to Worpdress role BUT not the opposite.
What we would like is that when a user arrive from Site A with the WP Role 2, UM automaticaly asign him the corresponding UM Role.
In the “For developpers” section of the help there is a code example mentionned earlier by danser81: ” Conditionally sync UM user role based on WP role (Gravity forms)”
/* This code will sync the UM role based on WP role using gravity registration */
add_action("gform_user_registered", "um_gravity_user_role_sync", 200, 4);
function um_gravity_user_role_sync($user_id, $config, $entry, $user_pass) {
$user = new WP_User( $user_id );
$wp_role = $user->roles[0];
// if WP role is subscriber, set UM role to member
if ( $wp_role == 'subscriber' ) {
update_user_meta($user_id, 'role', 'member');
}
}
Is there a way to adapt that code to what we are looking for?
Thank you VERY much in advance for any help.
Greetings from Berlin
Gui