# Entry

### onParticipantDisplay

**Description**\
This event is triggered in `CompetitionViewParticipant::display` (site).

```php
public function onParticipantDisplay($context, $item)
{
    // Do something
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$item` - the entry object.

### onParticipantBeforeDelete

### onParticipantAfterDelete

**Description**\
These events are triggered in `CompetitionModelParticipant::delete` (admin). If the plugin returns `false` for `onParticipantBeforeDelete` event then the entry is not being deleted.

```php
public function onParticipantBeforeDelete($context, $table)
{
    // Do something
    return true;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$table` - a reference to `CompetitionTableParticipant` object.

### onParticipantBeforeSave

### onParticipantAfterSave

**Description**\
These plugins are triggered in `CompetitionModelAppform::saveParticipant` (site) and `CompetitionModelParticipant::save` (admin). If the plugin returns `false` for `onParticipantBeforeSave` event then the entry is not being saved to the database and transaction is rolled back.

Please note that `onParticipantAfterSave` event is triggered inside the transaction that can be rolled back. To make sure that all the data is saved use the `*AfterSaveTransactionCommit` event.

```php
public function onParticipantAfterSave($context, $table)
{
    // Do something
    return;
}
```

**Arguments**\
`$context` - the context of the event: ‘com\_competition.participant’ or ‘com\_competition.appform’.\
`$table` - a reference to CompetitionTableParticipant object.\
`$isNew` - true for new entry, false otherwise.

### onParticipantBeforeSaveTransactionCommit

### onParticipantAfterSaveTransactionCommit

**Description**\
These plugins are triggered in `CompetitionModeParticipant::save` (admin). If the plugin returns `false` for `onParticipantBeforeSaveTransactionCommit` event then the entry is not being saved to the database and transaction is rolled back.

```php
public function onParticipantBeforeSaveTransactionCommit($context, $data, $isNew)
{
    // Abort save and all transaction
    return false;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$data` - the validated entry form data.\
`$isNew` - true for new entry, false otherwise.

### onParticipantAllowedCompetitionVotes

**Description**\
This event is triggered in `CompetitionModelParticipant::getVoteData` (site) and allows to modify the maximum allowed votes for contest. For example to provide additional votes for a user.

```php
public function onParticipantAllowedCompetitionVotes($context, $participantId, $competition, &$allowedVotes)
{
    // Set the allowed votes
    $allowedVotes = 2;
    
    return true;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$participantId` - the entry ID.\
`$competition` - a contest object.\
`&$allowedVotes` - allowed contest votes.

### onParticipantAllowedParticipantVotes

**Description**\
This event is triggered in `CompetitionModelParticipant::getVoteData` (site) and allows to modify the maximum allowed votes per entry. For example to provide additional votes for a user.

```php
public function onParticipantAllowedParticipantVotes($context, $participantId, $competition, &$allowedVotes)
{
    // Set the allowed votes
    $allowedVotes = 2;
    
    return true;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$participantId` - the entry ID.\
`$competition` - a reference to contest object.\
`&$allowedVotes` - allowed entry votes.

### onParticipantCheckVoteFrequency

**Description**\
This event is triggered in `CompetitionModelParticipant::getVoteData` (site). If the plugin returns `false` then vote frequency check is being skipped. This allows to provide an immediate vote for a user.

```php
public function onParticipantCheckVoteFrequency($context, $participantId, $competition)
{
    // Skip this check and allow to vote immediately
    return false;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$participantId` - the entry ID.\
`$competition` - a reference to contest object.

### onParticipantBeforeVoteSave

### onParticipantAfterVoteSave

**Description**\
These events are triggered in `CompetitionModelParticipant::vote` (site). If the plugin returns `false` for `onParticipantBeforeVoteSave` event then the vote is not being saved to the database and error is being retruned to a user.

```php
public function onParticipantBeforeVoteSave($context, $table, Registry $competitionParams)
{
    // Abort vote saving
    return false;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$table` - a reference to `CompetitionTableVote` object. `$competitionParams` - the parameters of competition in which a vote was taken.

### onParticipantBeforeChangeState

**Description**\
This event is triggered in `CompetitionModelParticipant::publish` (admin) before participant has its state changed.

```php
public function onParticipantBeforeChangeState($context, $pk, $value)
{
    // Abort vote saving
    return false;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$pk` - the ID of entry.\
`$value` - the value of the state: -2 - deleted; 0 - unpublished; 1 - published.

### onParticipantChangeState

**Description**\
This event is triggered in `CompetitionModelParticipant::publish` (admin) after entry has its state changed.

```php
public function onParticipantChangeState($context, $pks, $value)
{
    // Abort vote saving
    return false;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$pks` - a list of the primary keys to change.\
`$value` - the value of the state: -2 - deleted; 0 - unpublished; 1 - published.

### onParticipantBeforeApprove

**Description**\
This event is triggered in `CompetitionModelParticipant::approve` (admin) before entry has its approval state changed.

```php
public function onParticipantBeforeApprove($context, $table, $value)
{
    // Do something
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$table` - the entry table object.\
`$value` - the value of the state: 0 - unapproved; 1 - approved.

### onParticipantApprove

**Description**\
This event is triggered in `CompetitionModelParticipant::approve` (admin) after the entry has its approval state changed.

```php
public function onParticipantApprove($context, $pks, $value)
{
    // Do something
    return;
}
```

**Arguments**\
`$context` - the context of the event, ‘com\_competition.participant’.\
`$item` - a list of the primary keys to change.\
`$params` - the value of the state: 0 - unapproved; 1 - approved.
