2

In event registration confirmation emails, there is a link to manage (cancel/transfer) your own registration, if that box is ticked in the event setup. This is great! I want to add this to the reminder emails as well, but I can't work out what the 'PID' refers to in the link:

https://example.org/civicrm/?page=CiviCRM&q=civicrm/event/selfsvcupdate&reset=1&pid=[number]&cs=[string]

...where [number] is a number and [string] is a long string.

So cs is obviously the user's checksum, but what is pid in this context? It's not the event ID. I'm hoping I can grab this from a smarty tag somehow.

I'm on WordPress 4.9.8 and CiviCRM 5.4

2 Answers 2

3

In the Event self-service update form referenced in your link the URL fragment "PID" refers to the Participant ID (as correctly identified by Pradeep Nayak).

The mechanism for obtaining this and other information in a Smarty tag can be achieved using the CiviCRM API within Smarty as outlined in the docs here: https://docs.civicrm.org/dev/en/latest/api/usage/#smarty

The built-in API Explorer can assist in determining how to retrieve the information you require from the API and provides Smarty code for your use based on the queries you build.

The code for the "selfsvcupdate" form is here: https://github.com/civicrm/civicrm-core/blob/master/CRM/Event/Form/SelfSvcUpdate.php. See Line 216 for a direct link to the retrieval and lookup of the PID value from the URL.

Generic Example

{crmAPI var='result' entity='Participant' action='get' event_id=9 contact_id="user_contact_id"}
{foreach from=$result.values item=participant}
  {$participant.id}
{/foreach}

The code above will retrieve participant ID for the event with ID 9 for the currently logged in user.

Scheduled Reminder Example

Scheduled reminders are missing the necessary tokens to make this easy - after a bit of experimentation this code works - but it may be a bit fragile. It is however portable (limited static information, no hardcoded IDs)!

{capture assign=eventID}{event.event_id}{/capture}

 Event ID = {$eventID}<br /> // DEBUG Statement - DO NOT USE IN PROD

{capture assign=contactID}{contact.contact_id}{/capture}

 Contact ID = {$contactID}<br /> // DEBUG Statement - DO NOT USE IN PROD

{capture assign=participantID}{crmAPI var='result' entity='Participant' action='get' event_id=`$eventID` contact_id=`$contactID`}{$result.id}{/capture} 

Participant ID = {$participantID}<br/> // DEBUG Statement - DO NOT USE IN PROD

{if $participantID}
{capture assign=selfService}{crmURL p='civicrm/event/selfsvcupdate' q="reset=1&pid=`$participantID`&{contact.checksum}"  h=0 a=1 fe=1}{/capture}
{/if}

{if $selfService }
<a href="{$selfService}">{ts}Click here to manage your registration.{/ts}</a>
{/if}
7
  • Thanks this is super useful: I had no idea you could do that with Smarty. Works well in the API Explorer (which I also didn't know about!) except that it appears Participant.get isn't implemented in Smarty yet: Warning: Smarty error: {crmAPI} API (39Participant39, _39_get_39_) does not exist (join the API team and implement it!) in /var/www/html/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php on line 1100
    – Hugh
    Commented Sep 25, 2018 at 7:24
  • @hugh - that error is saying that it can't find the API key - all API calls should work in Smarty. Can you provide the exact smarty code you tried to use? Commented Sep 25, 2018 at 8:38
  • I tried a few things but here's the one I thought should work: {crmAPI var='result' entity='Participant' action='get' event_id=39 contact_id="contact.addressee_id"} {foreach from=$result.values item=participant} {$participant.id} {/foreach}
    – Hugh
    Commented Sep 25, 2018 at 10:09
  • 1
    @hugh Updated comment with new code example - tested and working in Scheduled Reminder. Watch out for the 3 "debug" statements I used to make sure the variables were being assigned properly! Commented Sep 28, 2018 at 19:33
  • 1
    This is awesome! Thanks so much, that works exactly as I was hoping.
    – Hugh
    Commented Oct 1, 2018 at 10:16
2

I believe PID is the participant ID registered of an event. This is the primary id from civicrm_participant table.

HTH

Pradeep

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.