Skip to content

Instantly share code, notes, and snippets.

View Pebblo's full-sized avatar
🏠
Working from home

Tony Warwick Pebblo

🏠
Working from home
  • Event Espresso
  • Liverpool, UK
View GitHub Profile
@Pebblo
Pebblo / my_custom_checkboxes_for_additional_question_groups.php
Last active January 8, 2024 23:49 — forked from joshfeck/my_custom_checkboxes_for_primary_question_groups.php
Check a question group box by default. For the Event Espresso 4 event editor. Additional Question group ID 1 (Personal Information).
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE_event_editor_questions_notice', 'my_custom_checkboxes_for_additional_question_groups' );
function my_custom_checkboxes_for_additional_question_groups() {
echo '<script>jQuery(
"#espresso_events_Registration_Form_Hooks_Extend_additional_questions_metabox input[value=\'1\']"
)
.prop( "checked", true );</script>';
}
@Pebblo
Pebblo / content-espresso_my_events-event_section.template.php
Last active November 7, 2023 13:09
This template is used within the My Events section of the EE4 User Integration add-on, [ESPRESSO_MY_EVENTS]. Currently the original template will only display registrations that are assigned to the current users contact (registrations made using the same details). So if you place a group registration for 5 tickets and provide different details f…
<?php
/**
* Template for the "event_section" content template for the [ESPRESSO_MY_EVENTS] shortcode
*
* Available template args:
* @type EE_Event $event event object
* @type string $your_tickets_title title for the ticket.
* @type int $att_id The id of the EE_Attendee related to the displayed data.
*/
$registrations = $event->get_many_related('Registration', array( array( 'ATT_ID' => $att_id ) ) );
@Pebblo
Pebblo / tw_filter_thank_you_text_based_on_pm.php
Created August 22, 2023 13:20
Example of how to filter the thank you page text based on the select payment method used on the EE_Transaction
<?php
add_action('AHEE__thank_you_page_overview_template__top', 'tw_filter_thank_you_text_based_on_pm');
function tw_filter_thank_you_text_based_on_pm($transaction) {
$payment_method = $transaction->payment_method();
if($payment_method instanceof EE_Payment_Method) {
if($payment_method->type() == 'Invoice') {
add_filter('FHEE__thank_you_page_overview_template__order_conf_desc', 'tw_filter_thank_you_text_for_invoice');
}
@Pebblo
Pebblo / tw_ee_set_ee_rest_datetime_order_by.php
Created June 28, 2023 13:55
Example of how to change the default order_by used in for datetimes within the EE REST API.
<?php //Do not include the opening PHP tag if you already have one
add_filter('FHEE__Read__create_model_query_params', 'tw_ee_set_ee_rest_datetime_order_by', 10, 3);
function tw_ee_set_ee_rest_datetime_order_by( $model_query_params, $query_params, $model ) {
if($model instanceof EEM_Datetime) {
// Match default order_by array to compare.
$default_order_by['DTT_ID'] = 'ASC';
// Check if the order_by currently set is the default order_by.
if( $default_order_by === $model_query_params['order_by']) {
// Order by DTT_ID => ASC so override that with DTT_EVT_Start => DESC
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action(
'wp_enqueue_scripts',
'tw_ee_change_default_ee_country_and_state_option',
20
);
function tw_ee_change_default_ee_country_and_state_option(){
$custom_js = 'jQuery(document).ready(function($){';
@Pebblo
Pebblo / tw_ee_csv_add_ticket_base_price.php
Created May 18, 2023 22:28
Example of how to add an additional 'Ticket Base price' column into the CSV.
<?php
add_filter(
'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
'tw_ee_csv_add_ticket_base_price',
20,
2
);
function tw_ee_csv_add_ticket_base_price(
array $csv_row,
@Pebblo
Pebblo / functions.php
Last active May 4, 2023 18:17
Example of how to hide tickets that do not have a capability assigned to them from logged in users, so logged in users will only see tickets that have a 'minimum capability' set on them they the user has on their account. This snippet checks for an event meta value 'hide_no_cap_tickets' from within the event before removing any tickets from view.
<?php //Please do not include the opening PHP tag if you already have one.
function tw_ee_hide_no_cap_tickets_from_logged_in_users( $return_value, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class) {
$event = $ticket->get_related_event();
$hide_no_cap_tickets_when_logged_in = $event->get_extra_meta( 'hide_no_cap_tickets', true );
if( $hide_no_cap_tickets_when_logged_in ) {
@Pebblo
Pebblo / ticket_headings.php
Created October 11, 2021 15:28 — forked from joshfeck/ticket_headings.php
Example that shows how to add some headings between ticket selector rows. Requires WordPress + Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'wp_enqueue_scripts', 'my_ee_add_ticket_row_headings', 11 );
function my_ee_add_ticket_row_headings() {
wp_add_inline_script(
'ticket_selector',
'jQuery( document ).ready(function($) {
$(".ee-ticket-tees-for-keys-golf-tournament-executive-sponsor")
.before( "<tr><td colspan=\'3\'><h3>Tees For Keys</h3></td></tr>" );
<?php //Do not include the opening PHP tag if you already have one.
add_filter(
'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
'tw_ee_csv_always_add_event_name',
20,
2
);
function tw_ee_csv_always_add_event_name(
array $csv_row,
@Pebblo
Pebblo / add_currency_code_spco.php
Last active January 27, 2023 14:59 — forked from joshfeck/add_currency_code_spco.php
Add currency code to the checkout display in Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function my_ee_add_currency_checkout() {
wp_add_inline_script(
'single_page_checkout',
'jQuery( document ).one( "ajaxStop", function() {
jQuery("#spco-payment-info-table")
.find(".spco-grand-total .total:nth-of-type(2)")
.append("<span>(CHF)</span>");