Skip to content

Commit

Permalink
trigger hook param added to update enrollments utils
Browse files Browse the repository at this point in the history
  • Loading branch information
harunollyo committed Jan 15, 2025
1 parent 9f08643 commit c6987a8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -9979,13 +9979,15 @@ public function get_local_time_from_unix( $time, $date_format = null ) {
* Execute bulk action for enrollment list ex: complete | cancel
*
* @since 2.0.3
* @since 3.2.0 $trigger_hook param added.
*
* @param string $status hold status for updating.
* @param array $enrollment_ids ids that need to update.
* @param bool $trigger_hook optional - trigger hook or not.
*
* @return bool
*/
public function update_enrollments( string $status, array $enrollment_ids ): bool {
public function update_enrollments( string $status, array $enrollment_ids, bool $trigger_hook = true ): bool {
global $wpdb;
$enrollment_ids_in = QueryHelper::prepare_in_clause( $enrollment_ids );
$status = 'complete' === $status ? 'completed' : $status;
Expand All @@ -10001,9 +10003,11 @@ public function update_enrollments( string $status, array $enrollment_ids ): boo
)
);

// Run action hook.
foreach ( $enrollment_ids as $id ) {
do_action( 'tutor_enrollment/after/' . $status, $id );
if ( $trigger_hook ) {
// Run action hook.
foreach ( $enrollment_ids as $id ) {
do_action( 'tutor_enrollment/after/' . $status, $id );
}
}

return true;
Expand Down

0 comments on commit c6987a8

Please sign in to comment.