I want to write a simple Wordpress plugin. The plugin will:
- Read (if set) a cookie from the visitor
- Send a cookie (if not set) to the visitor
- Depending on the cookie value I will redirect the user to a new pages
I found some documentation for getting/setting cookies through WP, and I'm guessing I can just issue a redirect from PHP. So I downloaded the WordPress Boilerplate (WPBP) code and so far so good. But I'm stuck at:
- Which WP callback should I hook into for my code? (init ?) I found the plugin documentation but I'm struggling to understand where this type of code should hook into.
- Should I put any of my code into the main/global portion of the WPBP file? Or only in the called back function.
- This plugin will run on a WP multisite installation. Does that mean my plugin code would run on every site? If so, how could I restrict my plugin code to run on only a particular site? (PHP check for a URI?)