Create Your Own RSVPMaker Events Listing Format

I’ve been working on creating a better API for developers who want to extend RSVPMaker, without hacking the core code of the plugin or overriding the pluggable functions. This example shows how you might take advantage of the get_future_events() function to write your own shortcode or widget code that outputs an event listing in a format of your own design.

get_future_events accepts 2 parameters, both optional — get_future_events($where,$limit)

$where is a SQL clause like ‘post_author=2’

$limit is a limit on the number of events that should be returned.

In this example, I added a shortcode that accepts where and limit as parameters that can be passed to the get_future_events function. You can also use before and after with either a specific MySQL formatted date or a date function like CURDATE() or DATE_ADD(). The past attribute directs RSVPMaker to use the get_past_events() function (which works the same way) instead. (This was only supposed to be a simple example, but I got carried away.)

I also included a showfield attribute to let you see the fields returned (the post_content body is hidden). In addition to all the normal $post properties, you get datetime (the full MySQL datetime for the event) and date (a formatted version). You can output the date in a different format by running the datetime data through PHP’s strtotime() to get a timestamp and then formatting your date with date() or strftime().

Here is the code, followed by a couple of examples.

[rsvpmaker_shortcode_demo]
Output:

January 25, 2018
RSVPMaker Entrepreneur Of The Year Dinner

January 27, 2018
Cub Scout Camping Trip

January 28, 2018
Cub Scout Camping Trip

January 29, 2018
Cub Scout Camping Trip

February 18, 2018
Sunday Seminar

[rsvpmaker_shortcode_demo showfields="1"]
Output:

stdClass::__set_state(array( 'postID' => '114918', 'ID' => '114918', 'post_author' => '1', 'post_date' => '2016-02-23 09:22:35', 'post_date_gmt' => '2016-02-23 14:22:35', 'post_content' => '[post content goes here]', 'post_title' => 'RSVPMaker Entrepreneur Of The Year Dinner', 'post_excerpt' => '', 'post_status' => 'publish', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_password' => '', 'post_name' => 'rsvpmaker-entrepreneur-of-the-year-dinner-2017-01-05', 'to_ping' => '', 'pinged' => '', 'post_modified' => '2016-11-30 19:07:40', 'post_modified_gmt' => '2016-12-01 00:07:40', 'post_content_filtered' => '', 'post_parent' => '0', 'guid' => 'http://rsvpmaker.com/?post_type=rsvpmaker&p=114918', 'menu_order' => '0', 'post_type' => 'rsvpmaker', 'post_mime_type' => '', 'comment_count' => '0', 'datetime' => '2018-01-25 19:00:00', 'date' => 'January 25, 2018', ))

[rsvpmaker_shortcode_demo where="post_title LIKE ‘%the%’"]
Output:

January 25, 2018
RSVPMaker Entrepreneur Of The Year Dinner

[rsvpmaker_shortcode_demo after="DATE_ADD(NOW(), INTERVAL 30 DAY)"]
Output:

January 25, 2018
RSVPMaker Entrepreneur Of The Year Dinner

January 27, 2018
Cub Scout Camping Trip

January 28, 2018
Cub Scout Camping Trip

January 29, 2018
Cub Scout Camping Trip

February 18, 2018
Sunday Seminar

[rsvpmaker_shortcode_demo past="1"]
Output:

December 4, 2017
Speechcraft Workshop

November 29, 2017
Speechcraft Workshop

November 27, 2017
Speechcraft Workshop

November 22, 2017
Speechcraft Workshop

October 18, 2017
Market and Manage Events with WordPress

  • Where do you put the php code? I want to try you example.

  • There is a mechanism documented here http://www.rsvpmaker.com/2010/12/changing-the-rsvp-form-other-customizations/ for adding custom code with a rsvpmaker-custom.php file, uploaded into the main plugins directory (above the rsvpmaker folder). RSVPMaker checks to see if a file with that name exists, and loads it if it’s present.

    Alternately, you could add the code to your theme’s functions.php (if it’s a custom theme or a child theme that won’t get overwritten by updates) or to a small plugin of your own design.