• Resolved Hybrid

    (@hybrid1969)


    I am trying to create a SSO callback URI within the a plugin i am creating and so far I have the following code –

    // inject session header
        function init_web_header(){
            include web_plugin_dir . '/pages/web-session.php';
        }
    
        // SSO callbacks
        function web_sso_callback() {
            global $wp_rewrite;
            $plugin_url = plugins_url( 'authcallback.php', __FILE__ );
            $plugin_url = substr( $plugin_url, strlen( home_url() ) + 1 );
    
            $wp_rewrite->add_external_rule( 'authcallback.php$', $plugin_url );
        }
    
        // init functions
        function web_init_action(){
            init_web_header();
            web_sso_callback();
        }
        add_action( 'init', 'web_init_action' );

    And within web-session.php i have –

    $location = $authsite . $authurl
                    . '?response_type=code&redirect_uri=' . $redirect_uri
                    . '&client_id=' . $client_id . '&scope=&state=' . $state;
    
                wp_redirect( $location );

    However the redirect is not working, any ideas what Iim doing wrong?

Viewing 1 replies (of 1 total)
  • Thread Starter Hybrid

    (@hybrid1969)

    For those struggling with wp_direct for some reason using
    add_action( ‘init’, ” ); does not work.

    you need to use
    add_action( ‘template_redirect’, ”, 1 );

Viewing 1 replies (of 1 total)
  • The topic ‘wp_redirect not redirecting’ is closed to new replies.