This should work, though untested.
<?php
add_action('send_headers', 'affiliate_redirect');
function affiliate_redirect() {
// it's possible to use 'if( !empty( $_GET['affid']) )'
if( isset($_GET['affid']) && '' != $_GET['affid'] ) {
if( empty($_COOKIE['affid']) )
setcookie('affid', $_GET['affid'], time()+2592000, "https://wordpress.stackexchange.com/");
header('Location: http://mysite.com/about/');
exit;
}
}
Related Posts:
- Display value of the GET parameter in a new URL page
- Identify User Language, Redirect to the corresponding page and Save the chosen language as Cookie
- WordPress Admin login redirect to homepage
- Redirection plugin – how to let the editor access the ‘redirection’ menu?
- SSL redirect loop using WordPress HTTPS Plugin
- Keep one user logged for a year?
- Disable saving comment details (name, e-mail) in cookie?
- Redirection Plugin: Redirect all URLs with a regular expression
- Security error WP 4.0 + WP phpBB Bridge [closed]
- Any way to use a custom Parameter for youtube embed without using an iframe?
- flush_rewrite_rules not working on plugin deactivation, invalid URLs not showing 404
- How to send “Location” header on plugin form submit event?
- Can’t access my WP dashboard: fatal error? [closed]
- Set cookie then immediantly refresh the page
- How to redirect Old Post URL to new Post and keep Old post Comments?
- What’s the _wp_desired_post_slug value for?
- Redirect all blog links from WordPress.com site to new domain
- Popup Cookie WordPress select language and section (Elementor)
- How to get variables from fucntion.php to my plugin files
- Do We Need to Validate, Sanitize, or Filter Simple Numerical Superglobals (Cookies and Post)?
- how can I link to a PlugIn admin-sub-menu page after processing a formular
- How does automatic redirection for the redirection plugin work?
- Changed permalink structure. Need help with redirecting old posts
- WordPress Redirect Not Working – AJAX Callback Response Not Picked Up
- How to Use Parameters with a Do_Action Function Within PHP Tags
- Landing Page Redirect Chain | http->https->https www
- Why is my staging subdomain not sending wordpress_logged_in cookies?
- How to delete Passwrd Protected posts cookies when a user logged out from the site
- How can I check if on specific plugin generated page or child
- Redirection based on location but without affecting search bots
- Page Restriction and Redirect for Particular Levels or user
- how to create site exit messages with destination url displayed
- WordPress Shortcode to get URL Parameters $_GET[‘name’] redirects for no reason at all
- How to save generated JWT token to cookies on login?
- WordPress Keeps Logging Out – What Tests Can I Run to Solve This?
- Redirect already logged in users away from a page to a specific page base on user role
- User Session and Stored Cookies not get removed
- Where does the cookie mo_page_views_counter come from?
- How to fix the woocommerce – adaranth.com redirection issue [closed]
- Redirecting thousands of posts that currently have no category in their permalink when changing permalink structure to include category
- How to handle cookies from a WordPress plugin on a cached page?
- How to use login_redirect with a user capability
- Removing Automatic Redirects Without Plugin
- Edit Permalink Structure For Custom Post Type or Modify .htaccess?
- Mask and Track Outbound Links
- How can I redirect some pages to new subdomain? [closed]
- Add to array, redirect and display
- Displaying content based on drop-down menu selection sitewide
- Get param from shortcode in plugin function
- shortcode – multiple instances of same parameter name in one shortcode instance
- Blurry images when loading the page first time
- Conditional custom redirect
- Making the ‘add to cart’ button redirect to PayPal
- PHP mobile redirect Endless loop
- How to force load a page in plugin?
- Adding a Tag Parameter / Filter to My Shortcode
- wp redirect 301 not working in wordpress page
- Preserve Search engine index while shifting to new Domain
- Janrain/Simple Modal under Redirected Domain
- Cookies set by a plugin in wordpress for tracking
- Codeless random token generation to pass into multiple tracking links in a single page load
- Redirect unloggedin users
- www redirects to another directory in wordpress
- Cookie value changes back to previous value after changing
- Redirect to a page while maintaining search query parameters without causing an infinite loop
- Block Google tracking on refuse consent of the user with plugin
- Can’t add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS
- How to update all in-site redirect URLs to destination URLs at once
- How to send new visitor to a splash page for only one time in wordpress?
- Reverse count page view and show on other page
- How can I store user preferences in WordPress and retreive them later?
- WordPress delete cookie
- redirect to a custom page
- Why does WordPress use cookies for /wp-admin and /wp-content/plugins for non-admin users [duplicate]
- .htaccess file doesn’t work, with hundred tries
- Implementation to count page visits of unique visitors based on a cookie
- Identify if the_post hook is being called from the admin post list
- admin-ajax.php not working properly on subdomains
- User Affiliate Token Generator?
- How can I save cookies to members
- Infinite 301 redirects after definitions in “Redirections” plugin?
- Clone a Post Tite and Custom Field into Custom Post type
- Using permalinks with parameters
- Direct URL to a template via plugin
- How to redirect from plugin page
- Template redirect inside of plugin not redirecting
- Can’t redirect to previous page after using GET
- set cookies for my whole site is not working
- Redirect url in plugin to somewhere else?
- How do I to override login redirect on specific pages?
- WordPress Plugin: Where should I put my cookies for cURL?
- How to link that “logged in” in “you must be logged in to post a comment” with custom login page on WordPress?
- Simple WordPress function / plugin to redirect a site
- Undefined constant error in pluggable.php
- How to resolve these findings from security audit
- ERROR: Cookies are blocked due to unexpected output – no access to FTP
- URL Redirect on GoDaddy platform [closed]
- Redirecting to page on form submit – Revue plugin
- how to make wordpress remember my choice
- Page with redirect