CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Conflict between Drupal captcha and profiles that require registration
Pages: [1] 2 3

Author Topic: Conflict between Drupal captcha and profiles that require registration  (Read 10162 times)

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Conflict between Drupal captcha and profiles that require registration
February 15, 2011, 06:02:27 pm
Circumstance:

Membership or event registration using a profile that enables drupal account creation AND drupal sign-up form has captcha enabled using the drupal captcha module.

Behaviour

  • A user that is not registered/logged in to Drupal enters details into profile as part of event registration
  • Captcha field is not displayed.
  • Drupal validation requires captcha field is entered, but it isn't displayed so you can't etc..
  • Users become abusive

Resolution (temporary fixes for people tearing hair out)

  • turn off captcha on drupal registration (=lots of spam) or
  • never use a profile that enables drupal account creation or
  • replace drupal registration with contribution page as membership sign up + profile that creates drupal account and use civiCRM's reCaptcha. - by replace I simply mean direct any 'create account' links to the contribution page

Long term...

It does seem a little beyond scope to have to integrate with a module contributed to drupal - where would that end?
Perhaps an easy way of replacing drupal account creation with a civicrm alternative.

And here I have gone way beyond my depth, but since I am rambling already...
 
Thinking about it the replace drupal account creation with contribution page approach is ok to a point but not so good in the light of Drupal 7 profiles as nodes approach - which gives loads of scope for social networking and so on.

It would perhaps be better to explore integrating with Drupal account creation, which could mean in effect that a profile is a node.

This may have the advantage of replacing the need for drupal-use civicrm-contact synchronisation.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Conflict between Drupal captcha and profiles that require registration
February 16, 2011, 08:21:19 am
Hi,

Would suggest to disable the captcha on drupal register, but enable it in the profiles in civicrm that you use for the membership, event and user registration.

The later will protect the drupal registration, on the other you can then add the account creation option.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Conflict between Drupal captcha and profiles that require registration
February 25, 2011, 08:53:32 am
Thanks Xavier, but... I've been experimenting noticed this from the helpful help bubble on the profile form next to 'include recaptcha'


Quote
reCAPTCHA is also not available when a profile is used inside the User Registration and My Account screens.

So in other words it will NOT protect the drupal user registration process from spammers -

Here's my assumption in case I have misunderstood you.

- I have a profile that has 'Drupal Registration' enabled - one and only one profile with this setting
- It does appear on the drupal registration form.

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Conflict between Drupal captcha and profiles that require registration
February 25, 2011, 08:57:47 am
Just to make clear...

Without Drupal captcha site registration is unprotected.

With Drupal captcha we can't use any profiles with 'create drupal account' enabled.

civiCRM reCAPTCHA will not protect drupal registration pages

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Conflict between Drupal captcha and profiles that require registration
February 25, 2011, 09:17:21 am
I've found some more threads on the subject and it seems that the above analysis is true... the workaround is to set up a membership / contribution page for account creation (with reCAPTCHA) enabled and redirect the drupal account creation page to that contribution page...

An elegant solution for that is offered by the Drupal Path redirect module (thanks subasmurf for that tip)

See last but one entry on this thread:

http://forum.civicrm.org/index.php/topic,7303.0.html

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Conflict between Drupal captcha and profiles that require registration
February 27, 2011, 07:25:36 am
That doesn't work! URL redirect will not redirect an existing path... and can't alias user/register either...

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Redirecting user/register
February 27, 2011, 08:04:42 am
This is a bit nasty but it is a solution...

Problem:

path_redirect module is intended to redirect paths that don't exist to existing ones - so if you enter an existing path such as user/register it hates you. It tells you to use an alias

If you use path alias to do this the civi/contribute path is truncated at contribute - dunno why - this redirects you to a page you don't have access to and wouldn't be useful

civicrm/contribute/transact?reset=1&id=10 becomes
civicrm/contribute

Solution:

Use path-redirect to set up a redirect from register (being an internal path that doesn't exist)

edit the path_redirect table in the database using MySQL Workbench or phpmyadmin -

update path_redirect
set source='user/register'
where source='register'

note your database probably has a prefix to the table name: mysite_path_redirect

Yuk but works!

planigan

  • I post occasionally
  • **
  • Posts: 37
  • Karma: 1
    • Allegheny CleanWays
  • CiviCRM version: 4.1.0
  • CMS version: Drupal 6.24
  • MySQL version: 5.0.90
  • PHP version: 5.2.13
Re: Conflict between Drupal captcha and profiles that require registration
March 03, 2011, 12:44:53 pm
Quote from: myles on February 25, 2011, 08:57:47 am
Just to make clear...

Without Drupal captcha site registration is unprotected.

With Drupal captcha we can't use any profiles with 'create drupal account' enabled.

civiCRM reCAPTCHA will not protect drupal registration pages

I just ran into this issue on my site as well. It seems like kind of a big deal to me.

Xavier, is there any chance of having a solution to this merged into core? Possible approaches off the top of my head...

(1) showing the Drupal recaptcha on profiles that have 'create drupal account' enabled
(2) bypassing the Drupal recaptcha on profiles that have 'create drupal account' enabled
(3) Enabling the CiviCRM recaptcha on Drupal registration pages

I haven't looked into the problem enough to know which might work the best.



Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Conflict between Drupal captcha and profiles that require registration
March 03, 2011, 04:38:15 pm

the main issue is:

civicrm calls:

        $res = drupal_execute( 'user_register', $values );

to create a user. other drupal modules can now inject fields like recaptcha etc and thus mess things up. not sure if there is an api that we can call that creates the user and does the other processing but not call the other hooks. someone can investigate how  user_import does this? (it seems to mimic a lot of the drupal account functionality)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

planigan

  • I post occasionally
  • **
  • Posts: 37
  • Karma: 1
    • Allegheny CleanWays
  • CiviCRM version: 4.1.0
  • CMS version: Drupal 6.24
  • MySQL version: 5.0.90
  • PHP version: 5.2.13
Re: Conflict between Drupal captcha and profiles that require registration
March 03, 2011, 06:09:06 pm
Quote from: Donald Lobo on March 03, 2011, 04:38:15 pm

the main issue is:

civicrm calls:

        $res = drupal_execute( 'user_register', $values );

to create a user. other drupal modules can now inject fields like recaptcha etc and thus mess things up. not sure if there is an api that we can call that creates the user and does the other processing but not call the other hooks. someone can investigate how  user_import does this? (it seems to mimic a lot of the drupal account functionality)

lobo

I looked into it a bit this evening. One option would be to create the user manually with the 'user_save' API call, but that would require quite a bit of extra logic to get the registration emails, etc working properly.

I came up with a different workaround, which is to retrieve the form and then remove the captcha element before processing it.

Code: [Select]
/*** inside createDrupalUser( &$params, $mail ) ***/

/* $res = drupal_execute( 'user_register', $values );*/

$form = drupal_retrieve_form('user_register', $form_state);
$form['#post'] = $form_state['values'];
drupal_prepare_form('user_register', $form, $form_state);

// remove the captcha element from the form prior to processing
unset($form['captcha']);

drupal_process_form('user_register', $form, $form_state);

I basically copied the implementation of the 'drupal_execute' function http://api.drupal.org/api/drupal/includes--form.inc/function/drupal_execute/6 and added the line to 'unset' the captcha element.

This seems to work on my local development machine, but I haven't deployed it yet. Would like some feedback before doing so.

mrp40

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6
Re: Conflict between Drupal captcha and profiles that require registration
March 09, 2011, 02:19:44 pm
Quote from: planigan on March 03, 2011, 12:44:53 pm
I just ran into this issue on my site as well. It seems like kind of a big deal to me.

Same. I have found that having a two-step process of people registering an account and then subscribing to a membership via a contribution page is just too hard for them.... users!  ::)

So I
  • turned the Drupal CAPTCHA module off for the user_register form (because of this conflict)
  • enabled account creation on my Contribution page profile
  • set up a redirect using the Path Redirect module from /contribute to /civicrm/contribute/transact... (not sure that this is required, but I had the contribute redirect set up anyway)
  • added a mod_rewrite rule for the multi-site Drupal 6 install (see below)

  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^.*theonlysitetoredirect.org.nz$ [NC]
  RewriteRule ^/user/register.*$ contribute [L,R=301]
  RewriteCond %{HTTP_HOST} ^.*theonlysitetoredirect.org.nz$ [NC]
  RewriteCond %{QUERY_STRING} ^.*q=user/register.*$ [NC]
  RewriteRule ^/$ contribute? [L,R=301]

Note that I only want this feature on one of the sites in the multi-site installation, hence the RewriteCond %{HTTP_HOST}. I also have not yet enabled reCAPTCHA on the contribution page/profile. I will do that once the bots start submitting my rather complex contribution page form.

It all works really well... but it's a bit of a pain. It would be nice to see a workaround built into a future version of CiviCRM that means both forms of account registration work without serious amounts of spam registrations. The CAPTCHA module is a must have if you keep the user/registration URL open.

Mark

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Re: Conflict between Drupal captcha and profiles that require registration
March 10, 2011, 04:05:53 am
Quote from: myles on February 15, 2011, 06:02:27 pm
Resolution (temporary fixes for people tearing hair out)

  • replace drupal registration with contribution page as membership sign up + profile that creates drupal account and use civiCRM's reCaptcha. - by replace I simply mean direct any 'create account' links to the contribution page

That is basically what we ended up doing, and I documented out solution here:
http://forum.civicrm.org/index.php/topic,18093.msg76728.html#msg76728

We had to leave Drupal "wide open" to user's creating their own accounts, but I needed to protect /user/register from receiving bogus accounts. With a little bit of .htaccess changes, I was able to eliminate completely access to the Drupal version of that URL and redirect people trying to get there to the proper CiviCRM page.

Actually it is doing a double redirect.
  • Redirect from /user/register to another pretty URL which is a Drupal contrib mod URL Redirect
  • The URL Redirect then redirects to the proper CiviCRM URL
That way we still only need to administer the CiviCRM URL in one spot, and that we can update via the GUI and not getting into config files on the server.
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

planigan

  • I post occasionally
  • **
  • Posts: 37
  • Karma: 1
    • Allegheny CleanWays
  • CiviCRM version: 4.1.0
  • CMS version: Drupal 6.24
  • MySQL version: 5.0.90
  • PHP version: 5.2.13
Re: Conflict between Drupal captcha and profiles that require registration
March 10, 2011, 10:37:39 pm
We would like users to be able to sign up for a drupal account independent of whether they have registered for an event or contributed. I guess the procedure is generally the same as what you and others have done. Create a CiviCRM profile to use for contact creation, allow anonymous users access to it, enable the CiviCRM reCAPTCHA on that profile, and create a redirect page for post-registraion, and add some more redirect magic to prevent direct access to the the Drupal registration page.

That is all just such an overly convoluted process for a task that should be very simple. There really should be a fix for this in core. The code that I posted above seems to work very well, and is transparent to the end user.

It allows the Drupal reCAPTCHA and the CiviCRM reCAPTCHA to co-exist. The Drupal reCAPTCHA is still used on all configured Drupal forms (including user registration) and the CiviCRM reCAPTCHA can protect event registration and contribution forms. Additionally, you can add the 'create drupal user' option to such CiviCRM forms and it just works.

Additionally, the Civi code still uses the standard drupal registration process, so all of the Drupal opt-in and verification settings are applied as expected.

I'm going to open an issue for this and submit the above code as a patch. We'll see if anything comes of it.

planigan

  • I post occasionally
  • **
  • Posts: 37
  • Karma: 1
    • Allegheny CleanWays
  • CiviCRM version: 4.1.0
  • CMS version: Drupal 6.24
  • MySQL version: 5.0.90
  • PHP version: 5.2.13
Re: Conflict between Drupal captcha and profiles that require registration
March 10, 2011, 11:01:16 pm
Submitted: http://issues.civicrm.org/jira/browse/CRM-7757

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Conflict between Drupal captcha and profiles that require registration
March 11, 2011, 07:19:33 am

would be great if a few other folks can apply the patch and confirm it works for them. If so, we can apply it for the next 3.4.alpha / beta version

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1] 2 3
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Conflict between Drupal captcha and profiles that require registration

This forum was archived on 2017-11-26.