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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Create PCP after registering for event
Pages: 1 [2]

Author Topic: Create PCP after registering for event  (Read 2707 times)

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 15, 2011, 09:19:06 am
As I wrote in my first post, I need to be able to create an Event and link it with the Contribution Page, so when someone registers for this Event, the PCP is automaticaly created for him.

What I did so far was to modify the Event details screen by adding new tab called Contribution Page, where user can link the Event with Contribution page. I've also modified the events table to store information that event has a contribution page and to store the page id. That's currently done by modifying the CiviCRM codebase, but I'd like to move it away (e.g. to plugin), so I can safely upgrade to a new versions. I'm pretty sure most of it could be done using hooks and custom templates, but I don't know if it's possible to modify the data object, so the screen will know what data have been saved previously. Or maybe I should just use a simple query in the hook? Anyway, I'll try that later if I have time. For now, getting the second part done is my priority.

The second step is to modify the registration process, so when someone registers, he can provide the details for PCP and it's being automatically created after registration. This will be fully done in the plugin. Could you please let me know ff you have any suggestions how to do it? I guess I could use the CRM_Contribute_Form_PCP_Campaign methods? If yes, how can I call those methods from the plugin? I'm working on it at the moment, so any suggestions will save my time.

Thanks a lot!

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: Create PCP after registering for event
May 15, 2011, 09:37:21 am

A few thoughts and comments:

1. I would not add a new tab for one field :) I would just modify the Online Registration Tab and add the "contribution page field" via the buildForm hook and customized template. I would store the value the user selected via the postProcess hook

2. Not sure what best practices are for modifying DB tables. To be really clean and safe, i would store this in a custom DB table and not extend CiviCRM's tables. The postProcess hook would store it in that table.

3. yes, u can call CRM_* methods from your plugin. U'll need to make sure u require the files u need etc

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

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 15, 2011, 09:44:27 am
Thanks Lobo. As I said I might have another look at the first part later if I have time. Thanks for suggestions.

About the CRM_Contribute_Form_PCP_Campaign methods - could you give me some more details here? I had a quick look at this class and it looks like it requires a few objects to be created (e.g. following call in the postProcess method: $params  = $this->controller->exportValues( )). Should I call some functions/methods first? If you have some example of how the PCP is being created, it would be great.

One more question - as far as I understand when participant registers for an event, the contact record is created, right? If yes, how can I get the participant contact_id in the postProcess hook?
« Last Edit: May 15, 2011, 11:18:31 am by peter »

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: Create PCP after registering for event
May 15, 2011, 08:30:31 pm
Quote from: peter on May 15, 2011, 09:44:27 am
One more question - as far as I understand when participant registers for an event, the contact record is created, right? If yes, how can I get the participant contact_id in the postProcess hook?

You can get it from the form object, not sure where it is stored, but do a debug print on the form object in the postProcess hook and hopefully one of the variables will have it. Most likely:

_participantId, so do: $form->getVar( '_participantId' ); to get the value

from which u can retrieve the contactID from the DB

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

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 16, 2011, 01:41:40 am
Thanks Lobo, I tried that yesterday, but I think I'll have to use the post hooh instead. Is the postProcess hook executed before all the inserts to the database? If yes, then I can only get the id of the existing contacts, but if it's a new contact, I'll need to wait for the insert to get the id, right?

If I do have to use the post hook, how can I access the form data? It looks like they're not in the request at this stage anymore...
« Last Edit: May 16, 2011, 01:50:18 am by peter »

mrfelton

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
    • KirkDesigns
Re: Create PCP after registering for event
August 28, 2011, 01:26:17 am
I'm looking to doing something very similar here. I want people to be abe to sign up for an event and get a PCP page for the event in return. Currently, the thought proces is.

1. Create an event
2. Create a contribution page
3. Use hook_civicrm_buildForm() to add a 'contribution page' field into the event form (this would be used to link the two together)
4. use hook_civicrm_postProcess() to create a PCP for the related contrition page on event sign up.

Whilst this will work, I think it's pretty clumsy from an administrators point of view. What would be better is if there was a way to associate a PCP page directly with an event, though I don't think the framework is really set up for that. Lobo - any ideas how much work there would be to allow PCP pages to be created and associated directly with Events?

- Tom

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Create PCP after registering for event
August 28, 2011, 06:55:06 am
Tom - I think there is general interest in connecting PCP's to event registration. I saw that you tried to take the Switchback's code and test-drive it (http://civicrm.org/blogs/scolson/extending-personal-campaign-pages and http://issues.civicrm.org/jira/browse/CRM-8534) but got a bit stuck with it. A few comments:

1. I'm not clear from either "specification" (yours above or steve's blog post) what the PCP's are actually tracking in these new use cases - and where a visitor goes if they click onward from a PCP (i.e. to an event registration form OR to a specified contribution page)?

2.  If we push to an event registration page ... are we ultimately still tracking the contributions ("soft credits" entries) that have come in as a result of folks using a PCP "portal" to register for an event? This would mean the thermometer and honor rolls on the actual PCP's can still be driven off the contribution_soft table with no changes.

OR

... are we really wanting to track the number of event registrations that came in via a PCP portal?

3. You say (#4 below) "create a PCP for the related contribution page on event signup" - which raises a few questions:
- Is the PCP really for a contribution page, or is the constituent promoting and sending folks onward to an event registration.
- It sounds like you want to create the PCP automatically - which we currently don't do. Current flow for creating a PCP allows constituent to make a explicit decision that they want to create a PCP, forces them to get a user account if they're not already authenticated, and then gives them a form to customize their personal "portal" with their "sales pitch" for the campaign. Do you see all of this happening automatically somehow???

A model that makes sense to me (and may be indeed what Switchback's code does ??) is:
- PCP "block" can be enabled for an event (as shown in Steve's blog screenshot) if it's a paid event
- Constituents can be given a link / button to "Promote this Event" (language configurable) on registration thank-you page
- They build their PCP as today, selling the event to their network
- PCP visitors are linked from the portal to event registration (or perhaps first to event info) - and the pcp ID is carried through into the registration process
- Event reg form can expose the honor roll message and nickname fields
- When the event fee is recorded (contribution record), a soft credit (contribution_soft) is created with the fee amount, nickname, honor roll msg
- PCP's display progress (as total fee amounts), honor roll as today by reading contribution_soft table

But I'm not clear if that's what you / your client is looking for.

Ideally you can hook up w/ Steve Colson via email or IRC and try to determine if there is substantive similarity in the requirements, and clarify some of the above issues in a blog post or wiki page, and THEN we can help figure out the best way to achieve it.
Protect your investment in CiviCRM by  becoming a Member!

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Create PCP after registering for event

This forum was archived on 2017-11-26.