Support » Plugin: Okta Authentication » Syncing existing WP user accounts with Okta and Okta with WP

  • I’m looking to use Okta to allow our users to authenticate easier to our WP environment. We already have users in WP and we also have an Okta account.

    I created a developer account test the integration to see how it would react with existing users and even though my email address is the same in both WP user account and the developer account I created, upon logging in via Okta, it created a new account for me. So instead of being an admin of the WP environment, I am a contributor.

    Is there any way to sync between the 2 systems, using the email as the identifier? Moving forward we’d be looking to have accounts created in Okta and create WP accounts which seems it would work ok (apart from the fact that Okta creates accounts with the email field blank) but just doesn’t seem to be a current solution for existing accounts…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Zillow Group

    (@zillowgroup)

    Thank you for the feedback! That feature was available but looks like it was lost in a recent commit. We’ll work on getting it back in there.

    Plugin Author Zillow Group

    (@zillowgroup)

    I take that back… there is a filter that can be applied to the user data that will allow you to use the email address instead of the username. Here’s the code:

    $user_data = apply_filters( 'okta_user_insert', array(
      'user_login' => $username,
      'user_pass'  => wp_generate_password(),
      'role'       => $default_role,
    ), $user_response );

    So in your case, you would just need to add a filter in your functions.php:

    add_filter( 'okta_user_insert', 'okta_user_filter', 10, 2 );
    function okta_user_filter( $user_data, $user_response ){
      $user_data['user_login'] = $user_response->email;
      return $user_data;
    }

    Let us know if that works for you.

    • This reply was modified 2 years, 6 months ago by Zillow Group.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Syncing existing WP user accounts with Okta and Okta with WP’ is closed to new replies.