setting the registration url in events list based on the query results of reg_event
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 19 May 2017 20:44:28 +0000 (16:44 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 19 May 2017 20:44:28 +0000 (16:44 -0400)
if an event has a registration record attached to it, it will have an edit url otherwise
it will have an add url. For the link next to the events in the events list admin view

setup/adminHooks.php

index 6bde7c0..aec1dcd 100644 (file)
@@ -66,9 +66,15 @@ add_filter(
         // Check if there's an existing reg_event record for the supplied event ID.
         require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
         $sql = "SELECT id FROM " .GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_event WHERE event='".$eventId."';";
-        $result = $this->wpdb->query($sql);
+        $result = $this->wpdb->get_var($sql);
+        $admin_page = GLM_MEMBERS_REGISTRATIONS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-registrations-events';
 
-        $return = "<td><a href='#'>Link for registration for event " . $result . "</a></td>";
+        if($result){
+            $return = "<td><a href='$admin_page&option=edit&registration_ID=$result'>Edit Registration</a></td>";
+            
+        } else {
+            $return = "<td><a href='$admin_page&option=add'>Add Registration</a></td>";
+        }
 
         return $return;
     },