Web, Power and Light https://webpowerandlight.com Construction Worker on the Information Super-Highway Thu, 08 Aug 2019 18:46:21 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.3 https://webpowerandlight.com/wp-content/uploads/2018/12/cropped-Web-Power-Light-HighRes-01-32x32.png Web, Power and Light https://webpowerandlight.com 32 32 wpal_has_tag_in_category($cats) https://webpowerandlight.com/2019/08/08/wpal_has_tag_in_categorycats/ https://webpowerandlight.com/2019/08/08/wpal_has_tag_in_categorycats/#respond Thu, 08 Aug 2019 18:46:21 +0000 https://webpowerandlight.com/?p=1814 wpal_has_tag_in_category($cats) Read More »

]]>
function wpal_has_tag_in_category($cats) {
    $found = false;
    $tags = isset($_SESSION[‘memb_db_fields’][‘groups’]) ? $_SESSION[‘memb_db_fields’][‘groups’] : ”;
    if ( is_array($cats)) {
        foreach($cats as $k => $v) {
            $cats[$k] = (int) $v;
        }
        $cats = implode(‘,’, $cats);
    }
    if (! empty($cats) && ! empty($tags)) {
        global $wpdb;
        $appname = memb_getAppName();
        $table = MEMBERIUM_DB_TAGS;
        $sql = “SELECT count(`id`) FROM `{$table}` WHERE `appname` = %s AND `id` IN ({$tags}) AND `category` IN ({$cats})”;
        $sql = $wpdb->prepare($sql, $appname);
        $found = (bool) $wpdb->get_var($sql);
    }
    return $found;
}
]]>
https://webpowerandlight.com/2019/08/08/wpal_has_tag_in_categorycats/feed/ 0