Skip to content

Instantly share code, notes, and snippets.

@nextab
Created June 15, 2021 10:56
Show Gist options
  • Save nextab/80832cab73f9b41647560dcac4ede9c1 to your computer and use it in GitHub Desktop.
Save nextab/80832cab73f9b41647560dcac4ede9c1 to your computer and use it in GitHub Desktop.
Diese kleine Funktion prüft lediglich per MySQL-Abfrage, ob ein registrierter Benutzer (der aktuell eingeloggt ist) Zugriff auf einen Online-Kurs hat (= product in DigiMember).
// Übergabe der Produkt-ID bei Funktionsaufruf; es wird als Rückgabe mitgeteilt, ob der aktuell eingeloggte Benutzer ein bestimmtes DigiMember Produkt erworben hat (true bei ja).
function nxt_check_dm_access($product_id = 2) {
global $wpdb;
$user_id = get_current_user_id();
$result = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}digimember_user_product WHERE product_id = $product_id and is_active = 'Y' and user_id = $user_id");
// echo '<pre>'; print_r($result); echo '</pre>';
// echo '<pre>'; print_r("SELECT * FROM {$wpdb->prefix}digimember_user_product WHERE product_id = $product_id and is_active = 'Y' and user_id = $user_id"); echo '</pre>';
if($result) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment