A powerful WordPress plugin that enables time-based page redirects with both global and individual user-specific rules. Perfect for limited-time offers, promotional campaigns, and time-sensitive content.
- Set specific start date and time for redirects
- Define duration in minutes
- Applies to all users visiting the page
- Automatically redirects users after the specified time expires
- Create per-user redirect rules based on first visit
- Set validity period in minutes
- Tracks each user's first visit timestamp
- Redirects only after the validity period expires from their first visit
- Works for both logged-in and anonymous users
- ✅ Timezone-aware: Displays times in user's local timezone
- ✅ UTC storage: Stores all timestamps in UTC for consistency
- ✅ Real-time server time display
- ✅ Cookie-based tracking for anonymous users
- ✅ Admin-friendly interface
- ✅ Multiple rules per page
- ✅ Easy to add, edit, and remove rules
- ✅ Excludes admin users from redirects
- WordPress 5.0 or higher
- PHP 7.2 or higher
- Download the plugin ZIP file or clone this repository
- Upload the
offer-redirectsfolder to/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to 'Offer Redirects' in the WordPress admin menu
cd wp-content/plugins/
git clone https://github.com/codersemon/offer-redirects.gitThen activate the plugin from WordPress admin.
- Flash Sales: Redirect users to a "sale ended" page after promotional period
- Limited Offers: Automatically expire special offer pages
- Event Registration: Close registration pages after deadline
- Webinar Pages: Redirect to replay page after webinar ends
- Trial Periods: Give each user X minutes access to premium content
- One-time Offers: Show special offer only for first X minutes of user's visit
- Time-limited Coupons: Display coupon code for limited time per user
- Content Teasing: Allow preview access for limited duration per visitor
- Go to WordPress Admin → Offer Redirects
- Under Global Offer Redirect Rules section:
- Select the Promoted Page (page to apply redirect rule)
- Set Start Date & Time (in your local timezone)
- Enter Duration in Minutes
- Choose Redirect To page
- Click Save All Rules
Example:
- Promoted Page: "Black Friday Sale"
- Start Date & Time: 2024-11-25 09:00
- Duration: 1440 minutes (24 hours)
- Redirect To: "Sale Ended"
Result: All users visiting "Black Friday Sale" page after 24 hours from start time will be redirected to "Sale Ended" page.
- Go to WordPress Admin → Offer Redirects
- Under Individual User Redirect Rules section:
- Select the Promoted Page
- Enter Validity in Minutes
- Choose Redirect To page
- Click Save All Rules
Example:
- Promoted Page: "Free Trial Dashboard"
- Validity: 180 minutes (3 hours)
- Redirect To: "Upgrade to Premium"
Result:
- User visits at 10:00 AM → Timer starts, no redirect
- User visits at 11:30 AM → Still within 3 hours, no redirect
- User visits at 1:15 PM → More than 3 hours passed, redirects to upgrade page
- Plugin stores the start time and duration in UTC
- When a user visits the promoted page, it checks current time vs. expiry time
- If current time >= (start time + duration), redirect happens
- All users experience the same redirect behavior
- When a user first visits the promoted page, their visit timestamp is recorded
- Logged-in users: Tracked by WordPress user ID
- Anonymous users: Tracked by secure cookie (valid for 10 years)
- On subsequent visits, plugin calculates: first_visit_time + validity_minutes
- If current time >= expiry time, redirect happens
- Each user has independent timer
- Display: All times shown in admin are in your local timezone
- Storage: All timestamps stored in UTC for consistency
- Conversion: Automatic conversion happens via JavaScript
- Server Time: Shows current server time (UTC) for reference
- Nonce verification for form submissions
- Data sanitization and escaping
- Admin capability checks
- Direct file access prevention
- Secure cookie implementation
The plugin provides a clean, intuitive admin interface with:
- Separate tables for Global and Individual rules
- Real-time server time display
- Add/Remove buttons for managing rules
- Dropdown selections for pages
- Datetime picker for scheduling
- Success messages after saving
The plugin stores data in WordPress options:
offer_redirect_rules- Global redirect rulesoffer_redirect_user_rules- Individual user redirect rulesoffer_redirect_user_visits- User visit timestamps
admin_menu- Adds admin menu pageadmin_init- Handles form submissionstemplate_redirect- Performs frontend redirectswp_ajax_render_offer_redirect_row- AJAX for adding rowswp_ajax_get_server_time- AJAX for time updates
Currently no custom filters (may be added in future versions)
The plugin includes comprehensive error logging. To enable debug logs:
- Enable WordPress debugging in
wp-config.php:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);- Check logs at
wp-content/debug.log
Log entries include:
- Rule processing details
- Redirect triggers
- User visit tracking
- Timestamp conversions
When you uninstall the plugin (not just deactivate), it will:
- Remove all redirect rules
- Delete user visit tracking data
- Clean up all database options
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Initial release
- Global redirect rules with start time and duration
- Individual user redirect rules with validity tracking
- Cookie-based anonymous user tracking
- Timezone-aware interface
- Real-time server time display
This plugin is licensed under the GPL v2 or later.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- GitHub: @codersemon
- Website: emonkhan.me
- Linkedin: codersemon
If you find this plugin helpful, please consider:
- ⭐ Starring the repository
- 🐛 Reporting bugs
- 💡 Suggesting new features
- 📖 Improving documentation
For questions or support, please open an issue on GitHub or contact at contact@emonkhan.me
Made with ❤️ for the WordPress community