Answers.Body: <p>I believe PID is the participant ID registered of an event. This is the primary id from civicrm_participant table. </p>
  
  <p>HTH</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-24T12:02:10.447Z
Answers.LastActivityDate: 2018-09-24T12:02:10.447Z
Answers.UserDisplayName: Pradeep Nayak
Answers.Body: <p>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).</p>
  
  <p>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: <a href="https://docs.civicrm.org/dev/en/latest/api/usage/#smarty" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/api/usage/#smarty</a></p>
  
  <p>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.</p>
  
  <p>The code for the "selfsvcupdate" form is here: <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Event/Form/SelfSvcUpdate.php" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/master/CRM/Event/Form/SelfSvcUpdate.php</a>. See <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Event/Form/SelfSvcUpdate.php#L126" rel="nofollow noreferrer">Line 216</a> for a direct link to the retrieval and lookup of the PID value from the URL.</p>
  
  <p><strong>Generic Example</strong></p>
  
  <pre><code>{crmAPI var='result' entity='Participant' action='get' event_id=9 contact_id="user_contact_id"}
  {foreach from=$result.values item=participant}
    {$participant.id}
  {/foreach}
  </code></pre>
  
  <p><em>The code above will retrieve participant ID for the event with ID 9 for the currently logged in user.</em></p>
  
  <p><strong>Scheduled Reminder Example</strong></p>
  
  <p>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)!</p>
  
  <pre><code>{capture assign=eventID}{event.event_id}{/capture}
  
   Event ID = {$eventID}&lt;br /&gt; // DEBUG Statement - DO NOT USE IN PROD
  
  {capture assign=contactID}{contact.contact_id}{/capture}
  
   Contact ID = {$contactID}&lt;br /&gt; // 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}&lt;br/&gt; // DEBUG Statement - DO NOT USE IN PROD
  
  {if $participantID}
  {capture assign=selfService}{crmURL p='civicrm/event/selfsvcupdate' q="reset=1&amp;pid=`$participantID`&amp;{contact.checksum}"  h=0 a=1 fe=1}{/capture}
  {/if}
  
  {if $selfService }
  &lt;a href="{$selfService}"&gt;{ts}Click here to manage your registration.{/ts}&lt;/a&gt;
  {/if}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T07:24:06.137Z
Answers.Text: 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`
Answers.UserDisplayName: Hugh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T08:38:39.333Z
Answers.Text: @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?
Answers.UserDisplayName: HomoTechsual
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T10:09:15.447Z
Answers.Text: 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}`
Answers.UserDisplayName: Hugh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T13:05:47.707Z
Answers.Text: I'm gonna try and repro this behaviour - give me some time :-)
Answers.UserDisplayName: HomoTechsual
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-28T19:33:12.110Z
Answers.Text: @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!
Answers.UserDisplayName: HomoTechsual
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-01T10:16:37.833Z
Answers.Text: This is awesome! Thanks so much, that works exactly as I was hoping.
Answers.UserDisplayName: Hugh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-01T10:17:22.107Z
Answers.Text: It was quite fun to work out :-D
Answers.UserDisplayName: HomoTechsual
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-24T12:17:38.917Z
Answers.LastActivityDate: 2018-09-28T19:32:37.337Z
Answers.LastEditDate: 2018-09-28T19:32:37.337Z
Answers.UserDisplayName: HomoTechsual
Body: <p>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:</p>
  
  <p><code>https://example.org/civicrm/?page=CiviCRM&amp;q=civicrm/event/selfsvcupdate&amp;reset=1&amp;pid=[number]&amp;cs=[string]</code></p>
  
  <p>...where [number] is a number and [string] is a long string.</p>
  
  <p>So <code>cs</code> is obviously the user's checksum, but what is <code>pid</code> in this context? It's not the event ID. I'm hoping I can grab this from a smarty tag somehow.</p>
  
  <p>I'm on WordPress 4.9.8 and CiviCRM 5.4</p>
  
Tags: <civievent><scheduled-reminders><5.0>
Title: Where does the PID value come from in the event self-cancellation link?
ThreadText: # Where does the PID value come from in the event self-cancellation link?
  
  (Asked by: username_0 on 2018-09-24)
  
  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
  
  **Tags:** civievent, scheduled-reminders, 5.0
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-09-24. Score: 3 | Accepted answer
  
  In the Event self-service update form referenced in your link the URL fragment "PID" refers to the Participant ID (as correctly identified by username_1).
  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} // DEBUG Statement - DO NOT USE IN PROD
  
  {capture assign=contactID}{contact.contact_id}{/capture}
  
   Contact ID = {$contactID} // 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} // 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 }
  {ts}Click here to manage your registration.{/ts}
  {/if}
  
  > **Comments:**
  > **username_0**: 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`  
  > **username_2**: @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?  
  > **username_0**: 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}`  
  > **username_2**: I'm gonna try and repro this behaviour - give me some time :-)  
  > **username_2**: @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!  
  > **username_0**: This is awesome! Thanks so much, that works exactly as I was hoping.  
  > **username_2**: It was quite fun to work out :-D  
  
  ---
  
  ### Answer by username_1 on 2018-09-24. Score: 2
  
  I believe PID is the participant ID registered of an event. This is the primary id from civicrm\_participant table.
  
  HTH
  
  Pradeep
  
  
  ---
  
  