Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Bespoke comments using vanilla authentication

Hi everyone, I'm loving using the vanilla forums software.
However on some of my website's pages (that are outside of the vanilla forum and don't have the vanilla code on them) I'd like to be able to allow Vanilla users to leave comments.

So my questions are: Is it possible to do this? And how? Is it safe to do this?

Basically, how can I check if a user is logged into my vanilla forum so I can let them use my bespoke comment section? If they are not logged in, I'd like to offer them a sign in/register popup box, that would then take them back to the page they were originally viewing.

Thanks a lot.

Comments

  • Options

    Just to clarify things a bit more, my forum is hosted on:
    mydomain.com/forum,
    and my articles that I want vanilla users to be able comment on is hosted on
    mydomain.com/articles

  • Options
    hgtonighthgtonight ∞ · New Moderator

    What type of software do you use to post articles?

    Vanilla offers pretty good integration with Wordpress. The approach required really depends on how you post articles.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    My question is more general than that really. I know a bit of PHP and MySQL myself so I'm mainly coding my own comment system, and don't want to have to rely on a 3rd party plugin. Just maybe a little PHP script I can include on the relevent pages.

    What I basically want is something like access to a variable like $user.

    If a user is logged in, $user->id would give me the user's id then I would be able to insert the comment into my database.
    If the user was not logged in $user->id would give null and I would have to present them with a vanilla login/registration popup box.

    Does you know if this is possible? And if so how?

  • Options
    hgtonighthgtonight ∞ · New Moderator

    I am sorry to say it, but doing this would require quite a bit of work. In this regard, your question is very broad and difficult to answer in simple post.

    I would approach it by using the Garden framework (the back-end for Vanilla) to develop some plugins and/or an application that can include the vanilla discussion code in them. I have used the Custom Pages plugin to create (mostly static) php pages and my own blogging plugin to run a site used by my community.

    In short, it is possible, but will require some effort on your part involving reading the documentation, the wiki (and updating it where you can:), and in some cases-- the source code.

    I hope you will take the time to learn about Vanilla. Welcome to the community!

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    I don't think it's as difficult as you think it is, to be honest. This snippet of code is knocking around the internet:

    define('APPLICATION', 'Vanilla');
    define('APPLICATION_VERSION', '2.0.16');
    define('DS', '/');
    define('PATH_ROOT', 'vanilla');
    ob_start();
    require_once(PATH_ROOT.DS.'bootstrap.php');
    ob_end_clean(); // clear any header output from vanila
    $Session = Gdn::Session();
    $Authenticator = Gdn::Authenticator();
    if ($Session->IsValid()) {
        $Name = $Session->User->Name;
    }
    

    which basically does what I want, but it seems a bit hacky to be honest. It's a shame to have to bloat my file with the entire bootstrap.php file, I'm sure there must be a quick and easy way to authenticate a user outside of the vanilla framework but on the same domain, and I'm convinced many, many Vanilla users would find this a useful feature to have.

  • Options

    you basically want a single sign on solution

    http://vanillaforums.org/page/singlesignon

    I'm convinced many, many....

    These sort of statement are nine to the dozen, if you want it build it.

    grep is your friend.

  • Options
    x00x00 MVP
    edited March 2013

    btw there is also an option of using Vanilla comment integration, you can look at the wordpress plugin for inspiration.

    It uses scraping, I would create a json API if I was doing to from scratch.

    grep is your friend.

Sign In or Register to comment.