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 / EE_google_calendar.php
Last active December 18, 2015 08:59
EE google calendar
<?php
$date_time_format = get_option('date_format') . " H:i";
$start_date_time = DateTime::createFromFormat($date_time_format,
$all_meta['start_date'] . " " . $all_meta['start_time']);
$end_date_time = DateTime::createFromFormat($date_time_format,
$all_meta['end_date'] . " " . $all_meta['end_time']);
$gc_start_date = $start_date_time->getTimestamp();
$gc_end_date = $end_date_time->getTimestamp();
$startyear = date('Y', $gc_start_date);
$startmonth = date('m', $gc_start_date);
@sidharrell
sidharrell / EE_multiple_css_dropdowns
Created June 12, 2013 22:47
EE Multiple CSS Dropdowns
<?php $id_num = rand(); ?>
<div id="lhsHeader<?php echo $id_num; ?>" class="leftBoxHeading_Off" onClick="lhsAction('<?php echo $id_num; ?>',true,'T6_Effective_Behaviour_Change');"><?php echo $button_text ?></div>
<div id="lhsExpander<?php echo $id_num; ?>" class="leftBoxExpander">
<div id="lhsInner<?php echo $id_num; ?>" class="leftBoxInnerPic"> <img src="<?php echo EVENT_ESPRESSO_UPLOAD_URL ?>templates/css-dropdown/images/left-box-inner-img.png" alt="Left image" height="18" width="287" />
<ul>
<?php echo espresso_list_builder($sql, 'css-dropdown/css_dropdown_display.php', '<li>', '</li>'); //Call out the template file ?>
</ul>
</div>
</div>
@sidharrell
sidharrell / firstdata_e4.php
Created July 2, 2013 00:16
fix for firstdata e4
<?php
// This is the full contents of the updated init.php file for firstdata_e4 for the fix added to 3.1.34-BETA
// This is for the gateway display
add_action('action_hook_espresso_display_offsite_payment_header', 'espresso_display_offsite_payment_header');
add_action('action_hook_espresso_display_offsite_payment_footer', 'espresso_display_offsite_payment_footer');
event_espresso_require_gateway("firstdata_e4/e4_vars.php");
if (!empty($_REQUEST['type']) && $_REQUEST['type'] == 'firstdata_e4') {
event_espresso_require_gateway("firstdata_e4/e4_ipn.php");
@sidharrell
sidharrell / gist:5924285
Last active December 19, 2015 08:18
send confirmation email to just primary attendee
function customized_espresso_email_after_payment($payment_data) {
global $org_options;
if ($payment_data['payment_status'] == 'Completed') {
event_espresso_send_payment_notification(array('attendee_id' => $payment_data['attendee_id'], 'registration_id' => $payment_data['registration_id']));
if ($org_options['email_before_payment'] == 'N') {
event_espresso_email_confirmations(array('attendee_id' => $payment_data['attendee_id'], 'registration_id' => $payment_data['registration_id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
}
}
remove_action('action_hook_espresso_email_after_payment','espresso_email_after_payment');
}
@sidharrell
sidharrell / gist:5924952
Last active December 19, 2015 08:19
new email shortcodes for original price and surcharge
function get_price_breakdown($attendee_id) {
global $wpdb;
$sql = "SELECT * FROM " . EVENTS_PRICES_TABLE . " p JOIN ";
$sql .= EVENTS_ATTENDEE_TABLE . " a ON (a.event_id = p.event_id AND a.price_option = (p.price_type OR p.member_price_type)) ";
$sql .= "WHERE a.id = %d;";
$temp = $wpdb->get_row($wpdb->prepare($sql, $attendee_id), ARRAY_A);
if ($temp['price_option'] == $temp['price_type']) {
$temp['pre_surcharge_price'] = $temp['event_cost'];
} else {
$temp['pre_surcharge_price'] = $temp['member_price'];
@sidharrell
sidharrell / gist:6360284
Created August 27, 2013 23:18
shortcode for displaying a list of upcoming event titles only
function show_event_titles($atts) {
ob_start();
global $wpdb;
$sql = "SELECT e.* FROM ". EVENTS_DETAIL_TABLE . " e ";
$sql .= " WHERE is_active = 'Y' ";//Makes sure event is active
$sql .= " AND event_status != 'D' ";//Makes sure event is not deleted
//$sql .= " AND event_status = 'O' ";//Un-comment to only show ongoing events
//Removing this line keeps events from showing that may be expired
$sql .= " AND start_date >= '".date ( 'Y-m-d' )."' ";
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
@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;
}
@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: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;
}