I have been working with Events Espresso for a little while now. It’s a comprehensive plugin but it lacks one handy little feature.. we needed the ability to show content based on the attending status of the currently logged in user. So if the logged in user ‘has purchased’ attendance to a specific event (or events list). Adding the following code to your theme functions.php file or a new plugin will give you access to a new shortcode.

The shortcode accepts ‘id’ and ‘noaccess’ arguments. The id accepts a single number for an event or a list of event ids separated by a | character. ‘noaccess’ is optional but when used it will show the provided message when a user has NOT purchased attendance to the event(s) specified.

The code

add_shortcode('ee_has_purchased', 'sb_ee_has_purchased');

function sb_ee_has_purchased($atts, $content) {
	get_currentuserinfo();
	global $wpdb, $current_user;
	
	$no_access = (isset($atts['noaccess']) ? wpautop($atts['noaccess']):'');
	
	if ($current_user->ID) {
		if (isset($atts['id'])) {
			if ($ids = explode('|', $atts['id'])) {
				$sql = 'SELECT COUNT(reg.REG_ID) AS attending
					FROM
						`' . $wpdb->prefix . 'esp_registration` reg
						JOIN `' . $wpdb->prefix . 'esp_attendee_meta` atm ON (reg.ATT_ID = atm.ATT_ID)
					WHERE
						reg.STS_ID IN ("RAP","TCM","ACT")
						AND reg.EVT_ID IN (' . implode(',', $ids) . ')
						AND atm.ATT_email = "' . $current_user->user_email . '"';
				if (!$wpdb->get_var($sql)) { //if not purchased then clear the content
					$content = $no_access;
				}
			}
		}
	} else {
		$content = $no_access;
	}
	
	return do_shortcode($content);
}

Usage

[ee_has_purchased id="123|345" noaccess="you do not have access to this content"]

A donate button!