• Resolved rebekahxd

    (@rebekahxd)


    Hello. Thank you for this plugin. It works great! I have one question: is it possible to save the user’s Discord ID to the database? I can see that the avatar URL, provider, and login token are saved. The display name (not including the user discriminator) and email address are also saved. Can the Discord ID be saved too?

Viewing 1 replies (of 1 total)
  • Plugin Author Claude

    (@claudeschlesser)

    Hello,

    you can use an action like this to save the username/discriminator:

    //Handle data retrieved from a social network profile
    function oa_social_login_store_extended_data ($user_data, $identity)
    {
    	if ($identity->source->key == 'discord')
    	{
    		$account = array_shift($identity->accounts);
    
    		if (isset ($account->username)
    		{
    			$parts = explode ('#', $account->username);
    			if (count ($parts) == 2)
    			{
    				update_user_meta ($user_data->ID, 'discord_username', $parts[0]);
    				update_user_meta ($user_data->ID, 'discord_discriminator', $parts[1]);
    			}
    		}
    	}
    }
     
    //This action is called whenever Social Login adds a new user
    add_action ('oa_social_login_action_after_user_insert', 'oa_social_login_store_extended_data', 10, 2);

    Please note that I haven’t tested the code, but it should do the trick.

    Also seen here:
    https://support.oneall.com/forums/discussion/8064/having-trouble-storing-the-discord-id-after-a-user-signs-in-with-discord-wordpress

    Best Regards,

    • This reply was modified 4 years, 7 months ago by Claude.
Viewing 1 replies (of 1 total)
  • The topic ‘Logging in with Discord’ is closed to new replies.