Skip to content

Instantly share code, notes, and snippets.

View lorenzocaum's full-sized avatar

Lorenzo Orlando Caum lorenzocaum

View GitHub Profile
@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'] );
@joshfeck
joshfeck / attendee_list.php
Last active August 29, 2015 14:01
Displays an attendee list after the content on the event details page. Displays the gravatar, first name, and last name of each attendee registered for an event. Requires Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// prints a per event attendee list right after the event details on a single event page
// you can change the action hook that's on the next line to display the list in another location
add_action( 'AHEE_event_details_after_the_content', 'ee_attendee_list' );
function ee_attendee_list(){
global $wpdb, $post;
@joshfeck
joshfeck / payment-settings-fixer.php
Created July 22, 2014 01:18
This can be installed as a plugin or if you have a site specific plugin already installed you can copy the add_action and the callback function to your plugin.
<?php
/**
* @package Payment Settings Fixer
* @version 0.1
*/
/*
Plugin Name: Payment Settings Fixer
Plugin URI: https://github.com/joshfeck
Description: A little patch to fix a strange issue in some WPEngine sites' admin for the Event Espresso 3 Payment settings page
Author: Josh Feck
@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');
@joshfeck
joshfeck / content-espresso_events.php
Last active August 29, 2015 14:07
Event Espresso 4 event content template part that will display only events that have tickets available on the event list page
<?php
/**
* This template will display a single event - copy it to your theme folder
*
* @ package Event Espresso
* @ author Seth Shoultes
* @ copyright (c) 2008-2013 Event Espresso All Rights Reserved.
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing *
* @ link http://www.eventespresso.com
* @ version 4+
@joshfeck
joshfeck / order-filter-event-category.php
Created October 29, 2014 03:22
Event Espresso 4's event category archives. Ordered by event datetime start and expired events removed.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// re-order the event category archives
add_filter('posts_orderby', 'edit_event_category_archive_orderby' );
function edit_event_category_archive_orderby( $orderby ) {
global $wpdb;
if( is_tax( 'espresso_event_categories' )) {
$orderby = "{$wpdb->prefix}esp_datetime.DTT_EVT_start ASC";
return $orderby;
@joshfeck
joshfeck / single-espresso_events.php
Created November 12, 2014 20:25
Custom single event template for the Espresso Events post type. This can be used in a Genesis child theme. Requires Event Espresso 4.
<?php
remove_action ( 'genesis_loop', 'genesis_do_loop' ); // Remove the standard loop
add_action( 'genesis_loop', 'custom_espresso_events_single_loop' ); // Add custom loop
// Optional: Remove post info
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
function custom_espresso_events_single_loop() {
@joshfeck
joshfeck / ee_meta_for_ee4.php
Created December 5, 2014 03:44
A little helper function for EE4 to use the old EE_META shortcode from EE3 on an event custom post. Idea from http://eventespresso.com/topic/how-to-use-ee_meta-in-event-expresso-4-for-backwards-compatibility/
function display_custom_meta_in_ee4( $atts ){
global $post;
extract( shortcode_atts( array( 'type' => '', 'name' => '' ), $atts ) );
$post_meta = get_post_meta( $post->ID, $name, TRUE );
return $post_meta;
}
add_shortcode( 'EE_META', 'display_custom_meta_in_ee4' );
@joshfeck
joshfeck / modify_permissions.php
Last active August 29, 2015 14:11
Allows any event editor set up with the EE3 Roles and Permission plugin to be able to use any questions in the system.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
//remove r&P question group filter so any event editor has all the questions:
add_action( 'init', 'ee3_modify_permissions_questions' );
function ee3_modify_permissions_questions() {
remove_filter('espresso_get_question_groups_for_event_where', 'espresso_rp_basic_get_question_groups_for_event_where', 10, 3);
}
@nerrad
nerrad / filter-events-to-posts.php
Last active August 29, 2015 14:13
Filter for injecting Event Espresso event post type events into everywhere posts are queried in WP
<?php
/**
* This is an alternative filter for adding events to posts.
*
* 1. Adds events to ANY query for posts (including core wp functions like wp_recent_posts() that suppress filters ).
* 2. Ensures we don't accidentally add posts (and events) into custom queries for other post types. (eg sliders).
*/
function add_espresso_events_to_posts( $WP_Query ) {
if ( $WP_Query instanceof WP_Query && ( $WP_Query->is_feed || $WP_Query->is_posts_page || ( $WP_Query->is_home && ! $WP_Query->is_page ) || ( isset( $WP_Query->query_vars['post_type'] ) && ( $WP_Query->query_vars['post_type'] == 'post' || is_array( $WP_Query->query_vars['post_type'] ) && in_array( 'post', $WP_Query->query_vars['post_type'] ) ) ) ) ) {