To enable Google Mail login in WordPress, you can use Google OAuth. This allows users to sign in to your website using their Google account. Here’s how to do it:
1. Create a Project in Google Cloud
- Go to Google Cloud Console.
- Create a new project or select an existing one.
- Navigate to API & Services > Credentials.
- Click Create Credentials > OAuth Client ID.
- Select the application type: Web Application.
- Specify the Authorized Redirect URIs:
- For local development:
http://localhost/wp-login.php
- For production:
https://your-domain.com/wp-login.php
- For local development:
- Save the Client ID and Client Secret.
2. Install a Plugin for OAuth
The easiest way is to use a ready-made plugin. Here are a couple of popular options:
Plugin: Nextend Social Login
- Install and activate the plugin from your WordPress admin dashboard.
- Go to the plugin settings (Nextend Social Login).
- Enable Google Login.
- Enter the Client ID and Client Secret obtained from Google Cloud Console.
- Specify the Redirect URI.
Plugin: Super Socializer
- Similarly, install and set up Google Login.
3. Configure Access and Validation
- Ensure your Redirect URIs are correctly configured in Google Cloud.
- Make sure HTTPS is enabled on the production server (Google requires secure connections).
- Allow user registration in WordPress if needed (enable it in Settings > General > Allow registration).
4. Test the Functionality
- Visit the WordPress login page (
/wp-login.php
). - You should see a “Sign in with Google” button.
- Test the login process to ensure the system correctly creates a WordPress user if they don’t already exist.
5. Customization (Optional)
If you want full customization, you can:
- Use Custom OAuth Integration with plugins like WP OAuth Server.
- Write your own plugin or function using the OAuth 2.0 PHP Client.