Tag Archives: sitecore YAF forum

Integrating YAF with Sitecore

In one of my projects, there’s a requirement to integrate a forum into the site that we develop using Sitecore. This forum will be used by the member of the site to as a way to communicate and have discussion among members.

After looking around it seems my options are either use Telligent Community forum or Yet Another Forum .Net (YAF). So I look into each forum to see which one fit the requirement, after a couple of minutes browsing their sites it seems YAF is the best option for us. While Telligen Community offers more seamless integration with Sitecore the fact that the client requirement for the forum is quite simple and YAF is an open source project it was more appealing to me.

So I start looking into integrating YAF with Sitecore, I start searching for articles and clues to how I actually can do this. Google is my best friend in this. After few keywords and a couple of sites that I visited it seems there are two options that I can take to integrate YAF.

The first would be the easiest, which is to install YAF as a stand alone application and wrap it up in an iframe. With this approach it would be cleaner and simpler to implement as we can easily upgrade YAF if we need to because we don’t have to change anything in YAF and the fact that it’s separated from our main app. The details on implementing this can be found here.

The second one would be to change the YAF code, and make it use the Sitecore membership provider. I decided to go with this path, because in the first option because it’s a standalone application and does not integrate the membership provider. Both side has their own users and roles, every time a user login to my main site and tries to access YAF, it would duplicate the user in YAF membership table. it feels like a hack to me and would cause a headache to keep both membership tables in sync.

Luckily I don’t have to do this from scratch, Brian Pedersen has managed to do this using older version of Sitecore and YAF. He was using Sitecore 6.0.1 rev. 090212 but any Sitecore version 6 will do, and YAF 1.9.3. Now unfortunately since I’m using YAF 1.9.6.1 I need to move any changes done by Brian to the latest version of YAF. That’s the easy part, soon as I successfully compiled the changes Brian’s done on YAF 1.9.3 to YAF 1.9.6.1, I was excited to try it out.

“Unable to find guest user” is the error message that I have to keep figure out for many hours. I dig through the store procedure to figure out what it’s trying to do, I dig through the forum posts looking for clues. And finally I found the answer, every user in YAF should be assigned to “Registered” role to enable them access to the forum. so what I did was login to admin pages, and assign “Registered” role to existing users and it works!.

Now for new users though, this is the bit of code that I use.

I didn’t get very far on implementing this though, but now that the existing user and new users can login to the site and start using the forum is a good sign for me so far. But I would expect some minor issue later on, I’ll deal with it then.