// Load Events Management Settings data
/* None - Need to figure out a smooth way to do this.
+*/
$eventsManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
unset($eventsManagementSettings['id']);
-*/
function glmMembersRegisterEvents($addOns) {
'slug' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
'actions' => $GLOBALS['glmMembersEventsAddOnValidActions'],
'config' => array(
+ 'settings' => $GLOBALS['eventsManagementSettings']
),
'shortcodes' => $GLOBALS['glmMembersEventsShortcodes'],
'shortcodesDescription' => $GLOBALS['glmMembersEventsShortcodesDescription']
*/
public function modelAction($actionData = false)
{
+ $allEvents = $this->getList();
+ //echo '<pre>' . print_r( $allEvents, true ) . '</pre>';
$status = $categoryId = null;
$action = '';
$settings = $events = $event = $categoryEvents = array();
*
* *** Also note that parameters will be in the context of the main front controller constructor. ***
*/
+
+// Setup rewrite for member detail pages
+add_filter('rewrite_rules_array', function($rules) {
+ $newrules = array();
+ $newrules['('.$this->config['settings']['canonical_event_page'].')/([^/]*)$'] = 'index.php?pagename=$matches[1]&eventId=$matches[2]';
+ return $newrules + $rules;
+});
+
+// Add memberslug query var
+add_filter('query_vars', function($vars) {
+ array_push($vars, 'eventId');
+ return $vars;
+});
+
+// On init, check if we need to flush the rewrite rules to pickup the new ones
+add_filter('init', function() {
+ $rules = get_option( 'rewrite_rules' );
+ if ( ! isset( $rules['('.$this->config['settings']['canonical_event_page'].')/([^/]*)$'] ) ) {
+ global $wp_rewrite;
+ $wp_rewrite->flush_rules();
+ }
+});
+