Skip to content

Instantly share code, notes, and snippets.

@stephenharris
stephenharris / wp-member-conditional-logic.php
Last active December 11, 2015 08:28
Using WP-Member to hide / show content depending on various conditions.
<?php
/**
* Using WP-Member to hide / show content depending on various conditions.
*
* This displaying content depending on:
* * Whether the member has **only** the guest level attached to them (this includes, but not restricted to logged out users)
* * Whether the member has the level 'Some Level' attached to theme
* * Otherwise if the user is logged in, displays a different message.
*
*/
@stephenharris
stephenharris / sh-no-wp-footer.php
Last active December 11, 2015 11:38
Displays a warning if `wp_footer()` is not called by a theme.
@stephenharris
stephenharris / wp-member-get-level-by-slug.php
Created January 23, 2013 21:55
Get membership level ID by Name / Slug
<?php
/**
* Get membership level ID by Name / Slug
*/
//Be careful - the name is not unique!
$level = wpmember_get_level_by( 'name', 'Basic Subscription' );
if( $level ){
$level_id = $level->term_id;
}else{
//Not found!
@stephenharris
stephenharris / venue-tooltip-upcoming-events.php
Last active December 13, 2015 22:59 — forked from stephenh1988/venue-tooltip-upcoming-events.php
Adds upcoming events to the venue tooltip in Event Organiser.
<?php
/**
* Adds upcoming events to the venue tooltip in Event Organiser.
*
* Uses the eventorganiser_venue_tooltip filter to append content to the venue tooltip. This tooltip appears when
* clicking a venue on a map (if tooltips are enabled).
* @uses eventorganiser_venue_tooltip.
*
* The filter passes 2 objects: the content of the toolip, the venue (term) ID
*
/**
* Display a list of upcoming events with Event Organiser
*
* Snippet that produces a simple list of the next 5 upcoming events.
*/
//Get upcoming '
$events = eo_get_events(array(
'numberposts'=>5,
'event_start_after'=>'today',
/**
* A function which adds classes to event pages corresponding to the event
* E.g. adds 'eo-event-cat-[cat slug]' class for each category the event belongs to.
* Adds 'eo-event-venue-[venue slug]' if the event has a venue
* Adds time based class: eo-event-future/past/running for future/past/running events
*
* @url http://wordpress.org/support/topic/problem-with-highlight-in-menu-change-url-of-events?replies=8#post-3458829
* Not tested
*/
add_filter( 'body_class', 'my_event_organiser_add_classes_to_event_body');
@stephenharris
stephenharris / venue-name-in-event-tooltip.php
Last active December 13, 2015 22:59 — forked from stephenh1988/venue-name-in-event-tooltip.php
Adds the venue's name to the content appearing in the tooltip when hovering over an event in fullcalendar
<?php
/**
* Requires Event Organiser 1.6+
*
* Adds the venue's name to the content appearing in the tooltip when hovering over an event in fullcalendar
* @uses eventorganiser_event_tooltip filter.
*
* The filter passes 4 objects: the content of the toolip, the post ID of the event, the occurrence ID
* of the event and the post object (the last one probably won't often bed needed).
* In this example we just need the first two.
@stephenharris
stephenharris / widget-calendar-link.php
Last active December 13, 2015 22:59 — forked from stephenh1988/widget-calendar-link.php
This code snippet replaces a link on the widget calendar with one that points to the a category for one of the events running on that date
@stephenharris
stephenharris / venue-page.php
Last active December 13, 2015 22:59 — forked from stephenh1988/venue-page.php
A page template that lists venues with Event Organiser
<?php
/**
* Template Name: Venue Archive
* Description: A page template that lists venues with Event Organiser. Just a simple example of what
* you can do.
*
* Instructions:
* 1. Create a page template for theme (it will probably need to be different from this template)
* 2. Ensure it has a template name (see "Temple Name:" above).
* 3. Create a page, selecting this template of the page.
<?php
/**
* This is a basic example of implementing front end creation of events with Event Organiser
* @see http://www.stephenharris.info/2012/front-end-event-posting/
* @see http://wordpress.org/extend/plugins/event-organiser/
*
*/
add_shortcode('my_event_form','my_event_form_shortcode_handler');
function my_event_form_shortcode_handler( ){