Skip to content

Instantly share code, notes, and snippets.

@Apina
Apina / registration_page.php
Created December 27, 2013 12:54
modified to display event description etc when event is maxed out, registration form is replaced with maxed out message
<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
do_action('action_hook_espresso_log', __FILE__, 'FILE LOADED', '');
//As of version 3.0.17
//This is a logic file for displaying a registration form for an event on a page. This file will do all of the backend data retrieval functions.
//There should be a copy of this file in your wp-content/uploads/espresso/ folder.
//Note: This entire function can be overridden using the "Custom Files" addon
if (!function_exists('register_attendees')) {
function register_attendees($single_event_id = NULL, $event_id_sc =0, $reg_form_only = false) {
//Declare the $data object
@Apina
Apina / espresso_create_wp_user.php
Last active August 29, 2015 13:57 — forked from sethshoultes/espresso_create_wp_user.php
Swapped this to check for the email rather than username, and to dampen any errors due to duplicate username. The code can be added to the themes functions.php file though it is recommended to use a site specific plugin: http://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/
add_action('action_hook_espresso_save_attendee_data','espresso_create_wp_user', 10,1 );
function espresso_create_wp_user($attendee_data) {
if( email_exists( $attendee_data['email'] ) == false ) {
global $org_options;
// Generate the password and create the user
$password = wp_generate_password( 12, false );
$user_id = wp_create_user( $attendee_data['fname'] . $attendee_data['lname'], $password, $attendee_data['email'] );
@Apina
Apina / estimatedreadtime
Last active August 29, 2015 13:58
Estimated Read Time plugin for WordPress
<?php
/*
Plugin Name: Estimated Read Time
Plugin URI: http://www.apinapress.com/
Description: Adds an estimated read time to posts (just above post content)
Version: 0.0.1
Author: Dean Robinson
Author URI: http://www.apinapress.com
License: GPL3
*/
@Apina
Apina / ee_add_jquery.php
Created July 30, 2014 09:42
This should no longer be required after 4.6.4 as there is an option in the Gateway settings -- Adds a little jQuery to automatically open the Payment options.
<?php
/*
Plugin Name: EE adds JavaScript to show the payment options automatically.
Description: EE adds JavaScript to show the payment options automatically.
*/
/* Begin Adding Functions Below This Line */
function ee_1() {
@Apina
Apina / example.php
Created September 29, 2014 10:34
EE4 US Phone and Zip validation: This needs to be added to a custom functions plugin or similar. It is very basic, for instance it loads on every page rather than just EE related pages, but should provide a basis for allowing validation. Also note that the addClass required isn't strictly necessary but may be useful.
function dr_validate() {
wp_register_script( 'drvalid', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.min.js', array('jquery'), '1.13.0', true );
wp_register_script( 'drvalid2', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/additional-methods.min.js', array('jquery'), '1.13.0', true );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'drvalid' );
wp_enqueue_script( 'drvalid2' );
}
add_action('wp_enqueue_scripts','dr_validate');
@Apina
Apina / custom_functions.php
Created November 11, 2014 08:35
EE3 - Modified function to make additional attendees free
//Please note that this is a non supported code snippet. Event Espresso will not provide general support for it, nor may it be updated.
//Please only use as an example for your own code
function espresso_make_additional_relay_teammates_free ($ext_att_data_source) {
global $wpdb;
//As this function is called for each attendee, lets bail if it's the primary attendee.
if( $ext_att_data_source['is_primary'] == true ) {
return;
@Apina
Apina / customfunction.php
Created November 20, 2014 11:58
EE4 (4.4.5) get the event ids in the SPCO
add_action('AHEE__registration_page_attendee_information__start', 'dxxx', 10, 1 );
function dxxx($event_queue) {
//var_dump($event_queue);
$my_registrations = $event_queue['items']; foreach($my_registrations as $a_reg) { echo $a_reg[event] -> ID(); }
}
@Apina
Apina / gist:fbbcf04cfce29f503086
Created December 9, 2014 07:38
EE4 detect if it's an EE4 event or event archive
<?php if ( get_post_type( $post ) == "espresso_events" || is_post_type_archive( "espresso_events" ) ) {
//do something
} else {
//do something else
}
?>
@Apina
Apina / associatedevents.php
Created December 15, 2014 07:58
Associated Events plugin for EE4 - adds meta box to EE4 venues to make it easier to see which events have this venue attached.
<?php
/*
Plugin Name: Associated Events for EE4
Plugin URI:
Description: Adds an Associated Events meta baox to EE4 venues, which lists which events the venue has been attached to.
Version: 0.0.1
Author: Dean Robinson
Author URI:
*/
@Apina
Apina / modify_reg_id.php
Last active August 29, 2015 14:14
EE4 modify registration ID
<?php
// Please do NOT include the opening php tag, except of course if you're starting with a blank file
function change_reg_code($new_reg_code, $registration) {
//create a new reg ID e.g. business-1598
$new_reg_code = "business-" . rand(1000, 10000);
//send the new reg code back to be used.