Custom Redirects
Custom Redirects lets you control where users go after signing in with Google. Instead of the default WooCommerce My Account page, send users to any URL on your site.
Custom Redirects is a PRO feature. Upgrade to PRO to unlock this functionality.
Default Behavior (FREE)
Without custom redirects:
- Users stay on the same page after One Tap
- Button redirects to WooCommerce My Account
- No customization available
With Custom Redirects (PRO)
You can:
- Set a global redirect URL
- Configure role-based redirects
- Use dynamic placeholders
- Preserve referrer URL
Configuration
Accessing Settings
- Go to Settings > OneTap Login
- Click Users tab
- Find Redirect Settings section
Global Redirect URL
Field: Post-login redirect URL
Enter a URL where all users should go after login:
https://yoursite.com/welcome/
Options:
| Value | Result |
|---|---|
| Empty | Default behavior (My Account) |
| Absolute URL | Exact destination |
| Relative path | Appended to site URL |
Examples:
# Absolute URL
https://yoursite.com/members/dashboard/
# Relative path
/dashboard/
# With parameters
/welcome/?new_user=1
Role-Based Redirects
Send different users to different destinations based on their role.
Configuration:
| Role | Redirect URL |
|---|---|
| Customer | /shop/ |
| Subscriber | /members/ |
| Contributor | /wp-admin/edit.php |
| Author | /wp-admin/ |
How it works:
- User signs in with Google
- Plugin checks user's role
- Matches role to redirect URL
- Redirects to appropriate destination
Priority Order
Redirects are processed in this order:
1. Role-specific redirect (if configured)
2. Global redirect URL (if configured)
3. Referrer URL (if "preserve referrer" enabled)
4. Default (WooCommerce My Account or wp-admin)
Dynamic Placeholders
Use placeholders for dynamic URLs:
| Placeholder | Replaced With |
|---|---|
{user_id} | WordPress user ID |
{user_email} | User's email |
{role} | User's role slug |
{referrer} | Previous page URL |
Examples:
# User-specific dashboard
/dashboard/?user={user_id}
# Role-based area
/portal/{role}/
# Preserve where they came from
{referrer}
Preserve Referrer
Setting: Preserve referrer URL
When enabled:
- Tracks the page user was on before login
- Redirects back to that page after login
- Useful for checkout/cart flows
How it works:
1. User on /product/widget/
2. Clicks Google sign-in
3. Completes authentication
4. Redirected back to /product/widget/
Referrer Exceptions
Some pages are excluded from referrer preservation:
- Login pages (
/my-account/,wp-login.php) - Admin pages (
/wp-admin/) - REST API endpoints
Use Cases
E-commerce Welcome Flow
Global redirect: /welcome/
Role redirect (customer): (empty, uses global)
All new customers see welcome page with:
- Account setup tips
- First-purchase discount
- Product recommendations
Membership Site Dashboard
Global redirect: /members/dashboard/
Role redirect (subscriber): /members/content/
Role redirect (premium): /members/premium/
Different membership tiers go to appropriate areas.
B2B Portal
Role redirect (customer): /portal/buyer/
Role redirect (editor): /portal/manager/
Role redirect (contributor): /portal/viewer/
Company roles map to portal sections.
Checkout Preservation
Preserve referrer: Enabled
Users signing in from checkout return to checkout.
Post-Purchase Onboarding
Global redirect: /onboarding/step-1/
After purchase and login, guide through setup.
Technical Details
Redirect Timing
Redirects happen:
- After successful authentication
- After WordPress session created
- After any welcome email sent
Redirect Method
The plugin uses:
wp_safe_redirect($url);
exit;
Only local URLs are allowed (security).
External Redirects
External URLs are not allowed for security:
❌ https://external-site.com/
✅ https://yoursite.com/page/
Hooks for Developers
Filter Redirect URL
add_filter('onetap_login_redirect_url', function($url, $user, $request) {
// Custom logic
if ($user->has_cap('premium_member')) {
return '/premium/dashboard/';
}
return $url;
}, 10, 3);
Filter by Login Method
add_filter('onetap_login_redirect_url', function($url, $user, $request) {
// Different redirect for One Tap vs Button
$method = $request['login_method'] ?? 'button';
if ($method === 'one_tap') {
return $url; // Stay on page for One Tap
}
return '/welcome/'; // Redirect for button
}, 10, 3);
Common Configurations
New User vs Returning User
add_filter('onetap_login_redirect_url', function($url, $user, $request) {
$is_new = get_user_meta($user->ID, '_onetap_login_count', true) <= 1;
if ($is_new) {
return '/welcome/';
}
return '/my-account/';
}, 10, 3);
WooCommerce Cart Redirect
add_filter('onetap_login_redirect_url', function($url, $user, $request) {
// If cart has items, go to checkout
if (WC()->cart && !WC()->cart->is_empty()) {
return wc_get_checkout_url();
}
return $url;
}, 10, 3);
Troubleshooting
Redirect Not Working
Possible causes:
- URL not saved in settings
- Another plugin overriding
- Cache showing old behavior
Solutions:
- Verify URL in settings
- Check for redirect conflicts
- Clear all caches
- Test in incognito
Wrong Destination
Possible causes:
- Role-based redirect overriding global
- Preserve referrer overriding
- Filter hook modifying
Solutions:
- Check role configuration
- Disable preserve referrer temporarily
- Check for custom code
External Site Redirect Blocked
Cause: Security feature prevents external redirects.
Solution: External redirects are intentionally blocked. Use hooks if you must redirect externally (not recommended).
Settings Summary
| Setting | Type | Default | Description |
|---|---|---|---|
| Global redirect | URL | (empty) | Default destination |
| Role redirects | URL per role | (empty) | Role-specific destinations |
| Preserve referrer | Checkbox | Off | Return to previous page |
Next Steps
- Domain Restrictions - Control who can register
- Role Mapping - Assign roles by domain
- User Settings - User configuration