server = $server; } /** * Register the user-related routes * * @param array $routes Existing routes * @return array Modified routes */ public function register_routes( $routes ) { $user_routes = array( // /users/me is an alias, and simply redirects to /users/ '/gcm/register/(?P.+)' => array( array( $this, 'register' ), WP_JSON_Server::READABLE ), ); return array_merge( $routes, $user_routes ); } public function register( $gcmid, $context = 'view' ) { return $this->pwapp_adduser($gcmid); } function pwapp_adduser($gcmid) { global $wpdb; $table_name = $wpdb->prefix . 'pw_gcmusers'; return $wpdb->insert( $table_name, array( 'created_at' => current_time( 'mysql' ), 'gcm_regid' => $gcmid, 'status' => "1", ) ); } } ?>