SOLVED: No captcha for registered user in submitcontent form

lemur 11 Dec, 2008
Hallo,

i try to use your greate software.

Is it possible to change submitcontent form:

for registered user it will be no captcha and in the name field - username?

Thanks.
GreyHead 11 Dec, 2008
Hi lemur,

You can certainly pre-fill information for registered users - you will find many examples in the Forums here.

It is much more difficult to turn the Captcha off for some users and not for others. It may be possible though.

Bob
lemur 12 Dec, 2008
Thanks for the quick reply.
It's OK with pre-fill information.

It is much more difficult to turn the Captcha off for some users and not for others. It may be possible though.



Isn't it a good challenge for developers, and not for us, dilettantes :-).

I am sure that many peoples need this capability.

Thanks.
Max_admin 12 Dec, 2008
Hi lemur,

its easy to do but must be with file hacks, do you need it so badly ?

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lemur 12 Dec, 2008

its easy to do but must be with file hacks, do you need it so badly ?
Max



Yes, I need it really.

Thanks.
GreyHead 12 Dec, 2008
Hi Lemur,

I just did something similar for a client. I've hacked out the main code chunks here

Turn Anti-spam OFF in the ChronoForms settings to suppress the ChronoForms tests. In the form HTML add
<?php
if ( $user->id == 0 ) {
  showImageVerification();
}
?>
. . .
<?php
function showImageVerification() {
?>
    <fieldset>
    <legend>Security check</legend>
    <div>Please type the letters from the image on the right into the box below.</div>
    <div><label for="chrono_verification">Β </label>
    <input id="chrono_verification" type="text" value="" name="chrono_verification"/>
	<img src="components/com_chronocontact/chrono_verification.php?imtype=1"/>
	</div>
	</fieldset>
<?php
}
?>
and in the OnSubmit code
<?php
$user = &JFactory::getUser();
if ( $user->id == '0' ) {
    $session =& JFactory::getSession();
	$sessionvar = $session->get('chrono_verification', 'default', md5('chrono'));
	if ( $debug ) echo "sessionvar: ".print_r($sessionvar, true)."<br />";
	$chrono_verification = strtolower($_POST['chrono_verification']);
	if ( $debug ) echo "md5(chrono_verification): ".print_r(md5($chrono_verification), true)."<br />";
	if ( md5($chrono_verification) != $sessionvar ) {
		showErrorMessage('Sorry, You have entered a wrong verification code, Please try again!!');
		JRequest::setVar('form', '');
		$rows[0]->autogenerated = '';
		unset($_SESSION['chrono_verification']);
		showform($_POST);
		return;
    } else {
		unset($_SESSION['chrono_verification']);
	}
}
?>
NB: not tested and may need debugging (I changed the 'if' tests here to use $user->id).

Bob

Later: edited to add two missing lines at the beginning of the OnSubmit code.
lemur 15 Dec, 2008
Thank you!

It works well. πŸ˜€

I will try to use this code in Chrono Comments too (hope, it is possible).

Soon I will pay Chrono Forms License and vote excellent Chrono Forms at Joomla.org

Leon
GreyHead 15 Dec, 2008
Hi Lemur,

Sorry I haven't tried with ChronoComments but something similar should work I think.

Bob
lemur 16 Dec, 2008

and in the OnSubmit code

if ( $user->id == '0' ) {
    $session =& JFactory::getSession();
	$sessionvar = $session->get('chrono_verification', 'default', md5('chrono'));
	if ( $debug ) echo "sessionvar: ".print_r($sessionvar, true)."<br />";
	$chrono_verification = strtolower($_POST['chrono_verification']);
	if ( $debug ) echo "md5(chrono_verification): ".print_r(md5($chrono_verification), true)."<br />";
	if ( md5($chrono_verification) != $sessionvar ) {
		showErrorMessage('Sorry, You have entered a wrong verification code, Please try again!!');
		JRequest::setVar('form', '');
		$rows[0]->autogenerated = '';
		unset($_SESSION['chrono_verification']);
		showform($_POST);
		return;
    } else {
		unset($_SESSION['chrono_verification']);
	}
}
?>
NB: not tested and may need debugging (I changed the 'if' tests here to use $user->id).



Excuse me,
I must come back.

In this code is missing inadvertently <?php above,

But that's not so bad.
Unfortunately, this code does not work: he accepts any code, and not only the right one.

Any help, please?

Thanks
GreyHead 16 Dec, 2008
Hi Lemur,

I've added the missing tag - good catch.

My version of the code works OK for me - I dont' know why it isn't working for you :-(

Bob
Max_admin 16 Dec, 2008
are you using the same Chronoforms versions ?

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lemur 17 Dec, 2008

My version of the code works OK for me - I dont' know why it isn't working for you :-(
Bob



Yes, your version of the code works OK for me too NOW.
The problem was that I had followed your council πŸ˜€ :

Turn Anti-spam OFF in the ChronoForms settings to suppress the ChronoForms tests.



Anti-spam must be ON.

Regards.
GreyHead 17 Dec, 2008
HI lemur,

Hmm . . . I understand what you are saying but that doesn't sound right . . . puzzled.

What happens when you are logged in as a user and try to submit with no AntiSpam image showing? My memory is that with Anti_Spam ON ChronoForms still looks for the token and fails asks for the anti-spam code.

Bob
lemur 17 Dec, 2008
Hallo, Bob

What happens when you are logged in as a user and try to submit with no AntiSpam image showing? My memory is that with Anti_Spam ON ChronoForms still looks for the token, fails to find it and asks for the anti-spam code.


😟 😟 😟

You are right!
When I logged in as a user and try to submit with no image showing AntiSpam, I get
"PCs are good ... you have entered a wrong code, please re-enter it! "

But if I turn off anti-spam and is not logged in, accept ChronoForms any code.

Should I attach pictures?

Thanks.
Leon
GreyHead 17 Dec, 2008
Hi Lemur,

I don't think pictures will help, please will you take a Form Backup using the icon in the Forms Manager and email it to me at the address in my sig. Then I can test the whole form on my setup here.

Bob
lemur 18 Dec, 2008

... please will you take a Form Backup using the icon in the Forms Manager and email it to me Bob



Hi, Bob.

Thank you for the support.
I've sent the backup.

Leon.
GreyHead 18 Dec, 2008
Hi leon,

Thanks, I've got your email and will take a look later today.

Bob
GreyHead 20 Dec, 2008
Hi Leon,

Sorry, it looks as though two lines were missing from the OnSubmit code - it should begin
<?php
$user = &JFactory::getUser();
if ( $user->id == '0' ) {
. . .


Bob

PS I went back and fixed my earlier posting.
lemur 22 Dec, 2008
Thank you very much!
Now it works well.

I will mark the Thema as SOLVED. :-))

Liebe Grüße,

Leon
This topic is locked and no more replies can be posted.