From: Laury GvR Date: Tue, 27 Sep 2016 15:36:01 +0000 (-0400) Subject: Helper functions for themes added X-Git-Tag: v2.7.0^2~17^2~7 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=f50d85b27a5e124528eba2bfa3f03d5505808d7f;p=WP-Plugins%2Fglm-member-db.git Helper functions for themes added One can now get_member_name and is_member from the theme. These functions are self-explanatory. --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index bb463420..5c1d32b8 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -282,9 +282,23 @@ add_filter('glm_associate_member', function( $attribute ) { return $result; }); -function is_member( $id = null ) { +function get_member_name( $id = 0 ) { global $wpdb; - if ($id) { + if ( $id ) { + return $wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = $id" ); + } + return $wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE member_slug = '".$GLOBALS['glmDetailSlug']."'" ); +} +function get_member_data( $field = false ) { + if ( $field ) { + global $wpdb; + $field = $wpdb->get_var( "SELECT $field FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE member_slug = '".$GLOBALS['glmDetailSlug']."'" ); + } + return $field; +} +function is_member( $id = false ) { + global $wpdb; + if ( $id ) { $result = $wpdb->get_var( "SELECT id FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = $id" ); } else { $result = $wpdb->get_var( "SELECT id FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE member_slug = '".$GLOBALS['glmDetailSlug']."'" );