Custom login script

Member

I need some customization to xenForo's login. Once the user has entered his credentials, a script would match two custom fields of his profile with two rows in a custom table within the xenForo database. If both match, user gets in. If not, user doesn't get in.

I have a PHP script which basically does this, I just don't know how can I insert it into xenForo's login. Where do I start?

Now, this should be ok, I followed the tutorial to the letter where applicable. How could I test this? It doesn't print anything but I guess it's not supposed to. At this point I just want to see that it's working.

Member

Sorry for the spam, making progress here tho, this is pretty cool stuff So, now I can execute stuff inside that function, for example sleep(10); worked fine. Alas, echo doesn't work anywhere. I'd need some way to debug the function - to make it print variables somewhere. Any ideas?

Member

I've never really taken the time to learn how to write PHP correctly inside XenForo, all of my mods (including the one above) are running on PHP files outside XenForo. Makes it simpler, I only have to worry about my PHP/HTML/Javascript not working.

Member

Member

Here's a few things to look into, but I don't know if it'll help:
- Many of the XenForo controllers have a "viewParams" variable in the PHP file that list variables that are accessible to the templates. For example, the XenForo file that shows the "Alerts" page has the "$alerts" variable in the viewParams on the PHP file.

If you can get it working that far, variables accessible to a template can be shown by simply putting {$variableName} in the template for the page you're working on. You can even do {xen:helper dump, $variableName} to see the full contents of the variable. That's especially useful if you need to see what's inside an array variable.

Member

I'm working on a login script so it isn't a page as such. Would it be feasible to define a variable, let's say a string "Hello world" within the actionLogin function and then render it in some template?

Member

I've already done a similar experiment where an external PHP feeds stuff into a xenForo template and it worked fine. This is a bit different because the modified actionLogin function should do the same. I've made a working plugin that extends the function, at this point it does nothing, it just includes the same stuff as the default actionLogin (by the way, does this overwrite the function or add to it?). I can't hook this file to a template the same way as the previous test as it would try to run the whole actionLogin inside a template.