Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter Hybrid

    (@hybrid1969)

    closing as obviously need to re-word my question

    Re-posted/re-worded post here –

    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 );

    Thread Starter Hybrid

    (@hybrid1969)

    ok np will do so, much appreciated.

    Thread Starter Hybrid

    (@hybrid1969)

    Ok i was setting add_action( ‘init’, ” ); twice

    i have now changed it to –

    // 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 );
    
            // The pattern is prefixed with '^'
            // The substitution is prefixed with the "home root", at least a '/'
            // This is equivalent to appending it to <code>non_wp_rules</code>
            $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' );

    so session seems to now be ok but the wp_redirect again is not working. I dont seem to be able to get both to work together for some reason

    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 );

    Really appreciate all the help you are giving as I am very very new to WP. All the codes works in pure PHP so i know it works outside of WP

    Thread Starter Hybrid

    (@hybrid1969)

    oh and is pulled from a custom table within the wordpress dbase

    Thread Starter Hybrid

    (@hybrid1969)

    I am building a custom SSO login system which will go into a custom user area as i don’t wont to completely rewrite the wp-login system

    and unfortunately add_action( ‘init’, ‘process_post’ ); doesnt appear to do anything at all, so should the add_action go into the plugin base file or somewhere else.

    Thread Starter Hybrid

    (@hybrid1969)

    the full path is wp-content/plugins/myplugin/pages/web-session.php’

    At the moment i am just trying to get the following code to be accepted

    session_start();

    if (isset($_SESSION[‘auth_characterid’])) {

    echo “Logged in. “.$_SESSION[‘auth_characterid’];
    exit;

    } else {
    if(is_page(‘Login’)) {
    echo “not logged in”;
    // deal with SSO redirect
    }
    }

    Thread Starter Hybrid

    (@hybrid1969)

    Thanks

    ok so i am using this format and I get the feeling i am not using it correctly

    In the plugin php file I have –

    function init_web_header(){
    include web_plugin_dir . ‘/pages/web-session.php’;
    }
    add_action(‘template_redirect’, ‘init_web_header’);

    Is this the correct place/usage. Sorry for all the questions.

    Thread Starter Hybrid

    (@hybrid1969)

    Ahhh ok sorry guys I miss read exactly what it does.

    Appreciate you correcting me otherwise I would have completely missed it.

    Which i have screwed something up in my code instead….well at least i can narrow down the issue better.

    Thread Starter Hybrid

    (@hybrid1969)

    That was my first attempt but because the redirect is inserted at the end of the wp_head section it doesn’t work.

    I has to come at the very top as well as the session variables that i am using.

    So what i will probably end up doing is injecting pages/templates via the plugin into the theme which is not what i really wanted to do.

    Thread Starter Hybrid

    (@hybrid1969)

    well i am creating a plugin not a theme and so i suppose the only way i can do it create templates that get copied across to the theme’s folder.

    But surely there must be a hook I can use to insert before the header/top of the page.

    I just cant find anything elegant or clean that would work.

    Any more suggestions?

    Hi Aeon

    Sorry for the delay, been a manic week.

    I disabled it but will try re enable and repeat the error.

    Thanks
    Hybrid

    Im having the same issue and the fix you suggested doesnt seem to work.

    However I did notice that whenever i import a fit, most of it gets cutoff and is missing when viewed.

    Any ideas on a solution?

    Much Appreciated as it looks great

Viewing 13 replies - 1 through 13 (of 13 total)