So following your advices I wrote the following but cannot get the link and my drophscat is set to 0 instead of 50
Code:
// Create a gallery object
$item = new \CB\Plugin\Gallery\Table\ItemTable();
$item->set( 'id', '[var3_params_gallery]' );
$mime = $item->mimeType();
$result = $item->path();
if ( $mime=== 'video/x-youtube' ) {
if ( preg_match( '%(?:(?:watch\?v=)|(?:embed/)|(?:be/))([A-Za-z0-9_-]+)%', $result, $matches ) ) {
$link = '<iframe src="https://www.youtube.com/embed/' . htmlspecialchars( $matches[1] ) . '?autoplay=1" loading="lazy" width="100%" height="100%" style="width: 100%; height: 100%;" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" class="position-absolute galleryVideoPlayer"></iframe>';
}
}
elseif ( $mime === 'video/x-vimeo' ) {
if ( preg_match( '%/(\d+)$%i', $result, $matches ) ) {
$link = '<iframe src="https://player.vimeo.com/video/' . htmlspecialchars( $matches[1] ) . '?autoplay=1" loading="lazy" width="100%" height="100%" style="width: 100%; height: 100%;" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" class="position-absolute galleryVideoPlayer"></iframe>';
}
}
// Create the event object
$row = new \CB\Plugin\GroupJiveEvents\Table\EventTable();
// Set the events data
$row->set( 'user_id', '[user_id]');
$row->set( 'group', 56 );
$row->set( 'title', '[var3_params_campaign]' );
$row->set( 'published', 1 );
$row->set( 'event', $link);
$row->set( 'params', '{"drophscat":"50","gid":"[var3_params_gallery]","gallery":"[var3_asset]"}');
// Validate and store the event
// if ( $row->getError() || ( ! $row->check() ) ) {
// return;
// }
if ( $row->getError() || ( ! $row->store() ) ) {
return;
}
// Create the initial attendence (event owner default attending)
$attend = new \CB\Plugin\GroupJiveEvents\Table\AttendanceTable();
$attend->set( 'user_id', $row->getInt( 'user_id', 0 ) );
$attend->set( 'event', $row->getInt( 'id', 0 ) );
$attend->store();