Option to disable captcha if logged in [SOLVED] with answer

You have a suggestion for a future version of phpMyFAQ? Then post it here!

Moderator: Thorsten

Post Reply
microbe
Posts: 7
Joined: Sun Jun 10, 2012 12:30 am

Option to disable captcha if logged in [SOLVED] with answer

Post by microbe » Sun Jun 10, 2012 1:46 am

Since people are manually approved when they register, we can assume that they are trusted. How about that if logged in no captcha for adding items. This also enables admins to add items without the pain of doing the captcha every time.
Last edited by microbe on Sun Jun 10, 2012 3:23 am, edited 1 time in total.
All the best,

Steve
Sorry...what was the question?

microbe
Posts: 7
Joined: Sun Jun 10, 2012 12:30 am

Re: Option to disable captcha if logged in

Post by microbe » Sun Jun 10, 2012 2:53 am

Hmmm...poking along because I am keen to make this happen I found this

/inc/PMF_Helper/Captcha.php

Code: Select all

if (PMF_Configuration::getInstance()->get('spam.enableCaptchaCode')) {
based on

Code: Select all

if (isset($auth)) {
    $loginTemplate = 'loggedin.tpl';
in index.php

I thought that using this might work && !isset($auth)

Code: Select all

if (PMF_Configuration::getInstance()->get('spam.enableCaptchaCode')  && !isset($auth) ) {
but it doesn't.

Am I heading in the right direction?
All the best,

Steve
Sorry...what was the question?

microbe
Posts: 7
Joined: Sun Jun 10, 2012 12:30 am

Re: Option to disable captcha if logged in [SOLVED]

Post by microbe » Sun Jun 10, 2012 3:16 am

Oh how I love solving my own questions :)

I found that the $auth value wasn't being passed into the function and without searching on how to make it global (with maybe some implications elsewhere) I decided to pass the value through.

Since I only really want this behaviour on the add page, in /add.php I have made this change on line 78 - it should work in any other page too

Code: Select all

'captchaFieldset'       => PMF_Helper_Captcha::getInstance()->renderCaptcha(
            $captcha,
            'add',
            $PMF_LANG['msgCaptcha']
        ),
Change the code to

Code: Select all

'captchaFieldset'       => PMF_Helper_Captcha::getInstance()->renderCaptcha(
            $captcha,
            'add',
            $PMF_LANG['msgCaptcha'],'',$auth
        ),
to catch the value

and pass the value into the function in /inc/PMF_Helper/Captcha.php

Code: Select all

public function renderCaptcha(PMF_Captcha $captcha, $action, $legend, $error = '')

becomes

Code: Select all

public function renderCaptcha(PMF_Captcha $captcha, $action, $legend, $error = '', $auth)
and then test for it being set...

Code: Select all

if (PMF_Configuration::getInstance()->get('spam.enableCaptchaCode')   ) {
becomes

Code: Select all

if (PMF_Configuration::getInstance()->get('spam.enableCaptchaCode')  && !isset($auth)  ) {
Now there is a captcha on the add FAQ page for those not logged in and it is not rendered for those who are.

Sweet!

Hope it helps someone else.
All the best,

Steve
Sorry...what was the question?

Thorsten
Posts: 14754
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Option to disable captcha if logged in [SOLVED] with ans

Post by Thorsten » Sun Jun 10, 2012 10:51 am

Hi,

very nice... will add this to 2.8

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

Thorsten
Posts: 14754
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Option to disable captcha if logged in [SOLVED] with ans

Post by Thorsten » Sun Jun 10, 2012 1:42 pm

Hi,

added for 2.8.0-alpha2: https://github.com/thorsten/phpMyFAQ/co ... 97f78d7a94

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

microbe
Posts: 7
Joined: Sun Jun 10, 2012 12:30 am

Re: Option to disable captcha if logged in [SOLVED] with ans

Post by microbe » Mon Jun 11, 2012 12:28 am

Cool, glad to be able to contribute.

I noticed your code is different to mine, mine works so do you see any problems leaving it like that?
All the best,

Steve
Sorry...what was the question?

Thorsten
Posts: 14754
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Option to disable captcha if logged in [SOLVED] with ans

Post by Thorsten » Mon Jun 11, 2012 6:44 am

Hi,

it's different because I added to the upcoming phpMyFAQ 2.8 alpha2 release which has a lot of improvements.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

jack9091
Posts: 1
Joined: Fri Nov 30, 2012 8:57 am

Re: Option to disable captcha if logged in [SOLVED] with ans

Post by jack9091 » Fri Nov 30, 2012 8:59 am

very nice...
Jack

Post Reply