Skip to content

Instantly share code, notes, and snippets.

View sidharrell's full-sized avatar

Sidney Harrell sidharrell

  • Vivian-Harrell Web Development Studios, LLC
  • Harpers Ferry, WV, United States
View GitHub Profile
@sidharrell
sidharrell / gist:7159162
Created October 25, 2013 18:07
modifications to show_cat_event_date_max shortcode functions
/*
This is an update to the function in uploads/espresso/custom_shortcodes.php
*/
function show_cat_event_date_max($atts) {
extract(shortcode_atts(array('max_days' => 'No Date Supplied',
'event_category_id' => __('No Category ID Supplied','event_espresso'),
'show_deleted' => false), $atts));
$max_days = "{$max_days}";
$event_category_id = "{$event_category_id}";
$show_deleted = $show_deleted == "true" ? true : false;
@sidharrell
sidharrell / gist:7142876
Created October 24, 2013 18:50
email admin 1 email for each attendee
function email_by_session_id_custom ($session_id, $send_attendee_email = TRUE, $send_admin_email = TRUE, $multi_reg = FALSE) {
global $wpdb;
$sql = "SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session = %s";
$attendees = $wpdb->get_col( $wpdb->prepare( $sql, $session_id ));
$admin_email_params = array('email_body'=>'');
foreach ($attendees as $attendee_id) {
$data = espresso_prepare_email_data($attendee_id, $multi_reg);
if ($send_attendee_email == 'true') {
$attendee_email_params = espresso_prepare_email($data);
event_espresso_send_email($attendee_email_params);
@sidharrell
sidharrell / gist:7141730
Created October 24, 2013 17:40
display an offsite payment link
function my_payment_link_display_function() {
echo '<a href="https://square.com"><img src="http://square_logo.gif"></a>';
}
add_action('action_hook_espresso_display_offsite_payment_gateway', 'my_payment_link_display_function');
@sidharrell
sidharrell / gist:7141370
Created October 24, 2013 17:19
override payment notification email so it only goes out to primary attendee
function event_espresso_send_payment_notification($atts) {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
global $org_options;
extract($atts);
if ($org_options['default_mail'] == 'Y') {
event_espresso_email_confirmations(array('attendee_id' => $attendee_id, 'send_admin_email' => 'false', 'send_attendee_email' => 'true', 'custom_data' => array('email_type' => 'payment', 'payment_subject' => $org_options['payment_subject'], 'payment_message' => $org_options['payment_message'])));
}
@sidharrell
sidharrell / gist:7087307
Last active December 26, 2015 03:39
for laggy paypal ipn messaging, set attendee payment status to "Pending"
// replaces line 24 of gateways/paypal/paypal_ipn.php
if (empty($_POST['ipn_track_id']) && ($_POST['payment_status'] == 'Completed' || $_POST['payment_status'] == 'Pending')) {
$payment_data['txn_details'] = serialize($_POST);
$payment_data['txn_id'] = $_POST['txn_id'];
$payment_data['payment_status'] = 'Pending';
} elseif ($myPaypal->validateIpn()) {
// replaces line 12 on gateways/paypal/init.php, to add the second line in
add_filter('filter_hook_espresso_transactions_get_payment_data', 'espresso_process_paypal');
add_filter('filter_hook_espresso_thank_you_get_payment_data', 'espresso_process_paypal');
@sidharrell
sidharrell / gist:7086385
Created October 21, 2013 16:03
email admin attendee cancelled notice
// substitute for lines 25-30 in my_events_page.php
while(list($key,$value)=each($_POST['checkbox'])):
$data = espresso_prepare_email_data($key, FALSE);
event_espresso_send_email(array(
'send_to' => $data->event->alt_email == '' ? $org_options['contact_email'] : $data->event->alt_email . ',' . $org_options['contact_email'],
'email_subject' => $data->event->event_name . ' ' . __('registration cancellation', 'event_espresso'),
'email_body' => $data->attendee->email . " | " . $data->attendee->lname . ", " . $data->attendee->fname . "<br>"
. "has cancelled for event:<br>"
. stripslashes_deep($data->event->event_name) . " | " . $data->attendee->price_option . "<br>"
. event_date_display($data->attendee->start_date) . ' - ' . event_date_display($data->attendee->end_date) . "<br>"
@sidharrell
sidharrell / gist:7029235
Created October 17, 2013 17:47
get event dates and times
<?php
function get_event_date_times($event_id = FALSE, $format = ARRAY_A) {
global $wpdb;
$sql = "SELECT e.start_date, e.end_date, ese.start_time, ese.end_time ";
$sql .= "FROM " . EVENTS_DETAIL_TABLE . " e ";
$sql .= "LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id ";
$sql .= "WHERE e.id = %d";
$results = $wpdb->get_results($wpdb->prepare($sql, $event_id), $format);
return $results;
}
@sidharrell
sidharrell / gist:6993165
Created October 15, 2013 15:13
add filter by event creator
// THIS IS FOR 2.1 BETA
// in the espresso calendar object add..
/**
* @var INT $_event_user_id
* @access private
*/
private $_event_user_id = 0;
// in public function espresso_calendar( $atts ) {
$atts = shortcode_atts( $defaults, $atts );
@sidharrell
sidharrell / gist:6889853
Last active December 25, 2015 00:39
custom espresso_get_total_cost to add amount paid and amount owed for use on payment overview
<?php
function espresso_get_total_cost_custom($payment_data) {
remove_filter('filter_hook_espresso_get_total_cost', 'espresso_get_total_cost');
global $wpdb;
//if for some reason attendee_session isn't setin the payment data, set it now
if(!array_key_exists('attendee_session',$payment_data) || empty($payment_data['attendee_session'])){
$SQL = "SELECT attendee_session FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id=%d";
$session_id = $wpdb->get_var( $wpdb->prepare( $SQL, $payment_data['attendee_id'] ));
$payment_data['attendee_session']=$session_id;
}
add_action('action_hook_espresso_save_attendee_data','espresso_create_wp_user', 10, 1);
function espresso_create_wp_user($attendee_data) {
if( username_exists( $attendee_data['email'] ) == NULL ) {
global $org_options, $wpdb;
// Generate the password and create the user
$password = wp_generate_password( 12, false );
$user_id = wp_create_user( $attendee_data['email'], $password, $attendee_data['email'] );
// Set the users details