We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28224
    • 17 Posts
    Got it working smiley

    Had this nagging doubt about the SSI.php include being in the snippet, so I removed it from the snippet and simply placed the includes such as sss_welcome() in the snippet. I then placed the SSI.php include right at the beginning of the Modx index.php. The ssi_login and ssi_logout now have the correct sessions and work as they should from Modx pages. smiley

    If you know of any potential problems that could result from doing this then please let me know.

    The only bit that is currently not working is that the SSI login does not redirect back to the referring page. This works in the SMF forum but is not working from Modx pages and users are simply directed to the forum when they log in. It would seem that it is looking for a session[’login_url’] but that this is not being set. Any ideas?
      • 22303 MODX Staff
      • 10,725 Posts
      Nope; you’re a pioneer at this point, and have effectively modified the MODx core to use SMF’s sessions. This will likely invalidate many add-ons that expect MODx user session data. As for the SMF functionality, yes, it expects that the code would set that session value at some point in the process, as would occur inside SMF itself.
        • 28224
        • 17 Posts
        A pioneer? Really not sure if that is a good thing .....

        Ok, here is the solution, or at least it is working for me.....

        1. Place include to SSI.php as the first line in the Modx index.php file as follows:

        <?php include_once(’forum/SSI.php’); ?> (assuming you have the SMF forum in a ’forum’ folder in your site root).

        2. Replace all instances of $_SESSION[’login_url’] with $_SESSION[’smf_login_url’] in the following SMF files:

        SSI.php
        LogInOut.php
        Security.php
        SubsAuth.php

        3. Create the following snippet called SMFlogin:

        <?php
        if ($ssi == ’ssi_login’){
        return $ssi($_SERVER[’REQUEST_URL’]);
        } else if ($ssi == ’ssi_logout’){
        return $ssi(’http://www.mydomainname.com/mylogoutpage.php’);
        } else {
        return $ssi();
        ?>

        4. Place the snippet in the template using [!SMFlogin? &ssi=ssi_function!]

        ssi_function being whichever ssi you want, such as ssi_login, ssi_welcome, etc. Revised this to allow multiple selections for flexibility - coded to specify a defined url on logout and to return user to current page on login - logout part works within the forum as well as from Modx pages.

        I am not a coder, so no doubt this could be done better, but the above appears to work without problems: login from Modx pages that redirects the user to the page the user was on when logged in and a logout redirection to a page that I specify, which could be a ’goodbye user’ type of thing.

        Hopefully the changes in the session will not cause any problems with SMF, but that should stop anything impacting upon Modx. Next I guess is to create a user in Modx when a user is created using the SMF registration sytem, including updating passwords etc.... Not sure if I am up to doing that.

        Does the above make sense and can you see any potential problems? Seems to work if the goal is simply to use SMF for user management and to use ssi includes outside of the SMF forum.