wpal_has_tag_in_category($cats)

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;
}

Leave a Comment