• Hi,

    I’m trying to make a very simple plugin that will redirect a blog post to another page if a query string is present.

    Here is my code:

    function triplify_init()
    {
    	global $blog_id;
    	if(isset($_REQUEST['triplify']))
    	{
    		$http = 'https://';
    		$https = $_SERVER['HTTPS'];
    		if(!empty($https)){
    			$http = 'https://';
    		}
    		header('Location: '.$http.$_SERVER['SERVER_NAME'].'/triplify/'.$blog_id.'/');
    		exit();
    	}
    }
    add_action('init', triplify_init());

    The plugin is activated however if I go to https://example.com/?triplify nothing happens (it just loads the page like normal) however if I go to https://example.com/wp-admin/?triplify the plugin does run.

    My understanding is that the init action should run regardless of what page you’re looking at.

    Can anyone point me in the direction please?

    Thanks

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Redirect blog’ is closed to new replies.