Merge pull request #16574 from civicrm/5.23
[civicrm-core.git] / CRM / Event / BAO / Participant.php
index 78e03b3c401245f836b46ce41479739584e127f6..b24c279aa80455fedab47a4f5fdc81036e049252 100644 (file)
@@ -969,6 +969,21 @@ WHERE  civicrm_participant.id = {$participantId}
     }
   }
 
+  /**
+   * Get the ID of the default (first) participant role
+   *
+   * @return int
+   * @throws \CiviCRM_API3_Exception
+   */
+  public static function getDefaultRoleID() {
+    return (int) civicrm_api3('OptionValue', 'getvalue', [
+      'return' => 'value',
+      'option_group_id' => 'participant_role',
+      'is_active' => 1,
+      'options' => ['limit' => 1, 'sort' => 'is_default DESC'],
+    ]);
+  }
+
   /**
    * Get the additional participant ids.
    *