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 CiviEvent (Moderator: Yashodha Chaku) »
  • Subscribe contact to event via PHP script
Pages: [1]

Author Topic: Subscribe contact to event via PHP script  (Read 1154 times)

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Subscribe contact to event via PHP script
February 19, 2013, 02:31:41 pm
Hi,
Is there a way to programmatically subscribe a contact to an event?

or

Is it possible to modify the event registration procedure like:
1. Show the contact data in read-only registration profile
2. Ask the contact if this info is correct
3. If yes then register him for the event
4. If not - make the profile fields editable (or use another profile) so he can update the info and then register

I am asking this because we have huge problem with contacts who every time they register for an event overwrite their info that is already in the database.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Subscribe contact to event via PHP script
February 20, 2013, 04:37:27 am
Quote from: rminkov on February 19, 2013, 02:31:41 pm
Is there a way to programmatically subscribe a contact to an event?

Yes, via the API.

Quote from: rminkov on February 19, 2013, 02:31:41 pm
Is it possible to modify the event registration procedure like:
1. Show the contact data in read-only registration profile
2. Ask the contact if this info is correct
3. If yes then register him for the event
4. If not - make the profile fields editable (or use another profile) so he can update the info and then register

1-3 you could do with a Drupal module and the CiviCRM API. Step 4 sounds like you could just send them to the default (regular) CiviCRM Event Registration page.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Subscribe contact to event via PHP script
February 20, 2013, 12:52:19 pm
You might want to check with Colemanw on irc - but I think the webform workflow can be a bit like that?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Subscribe contact to event via PHP script
February 21, 2013, 02:44:25 pm
I have come to the point where I want to give the general public as little power over our database as possible. Even those seemingly simple 2 questions you proposed (is this info correct? and update your info) are inevitably going to be misused by some small but annoying percentage. Heck I have a hard enough time getting our staff to use Civi forms correctly nevermind the general public!
So it might be worth expounding on your problem a bit more, namely:
- What does your form look like now?
- How is it being misused?
- Is your scenario for anon users or those logged-in or identified by a hashed link?
Try asking your question on the new CiviCRM help site.

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Subscribe contact to event via PHP script
February 22, 2013, 04:23:41 am
Hi Coleman,
Exactly our problem here - the registration form works ok in most of the cases, but it still could be misused by "some small but annoying percentage" - not carefull enough, or using browsers with disabled JS.

We deal exclusively with with anon users, as they don't like to remember yet another password :)
We are implementing the hashed links for event registration at the moment, I tested it and I don't expect problems there.

Here is one real example of our registration form - http://www.ceps.eu/civicrm/event/register?id=472&reset=1.
We use JS to hide all the profile fields except the email field.
One enters his email and if it is matched to a contact he is presented with button Continue and the registration is done, if such email is not in the database then the rest of the fields are exposed and after they are filled up the registration is done.

One big problem we face - when for some reason the user is presented with all the fields from the profile (when JS is disabled for example). He enters his details and registers. If the email doesn't match a record then new record is created - this is OK.
But when the email entered matches a contact record then this record is updated with the data from the rest of the fields. This is what we don't want. Some people type always in all/small caps, the company name is shortened or misspelled, etc. We generate list of participants for each event and we are not sure if the correct spelling of the company name, personal names, etc. was not changed during the registration process by the registrants.

One really elegant solution would be in the profile settings to be able to select action on email match - like the options we have when importing contacts via CSV - Update, Fill, Skip,.... We are willing to sponsor this.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Subscribe contact to event via PHP script
February 22, 2013, 09:17:07 am
I think your proposal while seemingly elegant presents a big security hole which will be unacceptable for most if not all orgs using CiviCRM (including yours). It would allow an anonymous user to look up the name and address of any contact in your database via your event registration forms. It would also allow spammers to test email addresses. Not good.
Try asking your question on the new CiviCRM help site.

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Subscribe contact to event via PHP script
February 22, 2013, 12:32:21 pm
What about the following scenario:
We always present an empty event registration form.
To register people have to fill up all the fields.

Then - if there is match on the email - disregard the info and register the match.
- if there is no match - create new record with the data and register it.

The goal is not to update the database in case of a match.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Subscribe contact to event via PHP script
February 22, 2013, 02:24:39 pm
I wouldn't say that's the goal, I would say the goal is to avoid overwriting correct info with incorrect info. Whether the new info is correct or the old info is correct is difficult to determine by a machine. For example if the person has changed their home address then you actually do want the new info and discarding it would be a mistake.

Here's what I do. I wrote a bit of code that implements hook_civicrm_pre and does the following:
- If the person has typed in ALL UC or all lc it will change to Title Caps
- A bit more cleanup (delete nick-name if is identical to first name, prevent accidental deletion of some fields, etc)
- If the person does not have "Access CiviCRM" permission (i.e. not your staff) and they update their info, it will send an email to staff alerting them of the change.
The code is at https://github.com/woolman/drupal-modules/blob/master/woolman_website/woolman_website.module#L303 (note this is a D6 module)

I also recommend turning on CiviCRM's advanced logging feature so you get a detailed record of all changes to your contact records.
Try asking your question on the new CiviCRM help site.

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Subscribe contact to event via PHP script
February 25, 2013, 06:14:03 am
Thank you, I will test your code on our registration procedure.

Still it doesn't tackle our other problems like:
- overwriting company name "European Commission" with entries like "EC" or "EuroComm", "Commission" ...
- overwriting personal names - Robert with Bob, etc.
- using mixed case but the wrong way - rOBERT

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Subscribe contact to event via PHP script

This forum was archived on 2017-11-26.