• Resolved zittercraft

    (@zittercraft)


    Hi there, great plugin, very developer-friendly! Is there a possibility to query any users depending on their given consent? I created a CF7-form for the privacy-policy, works fine. But I want to show the form only if
    – a user is logged in
    – and has yet to give his consent.

    Can you give me a hint? Thanx a lot!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi there!

    You can check if a user has given a particular consent like this:

    
    $dataSubject = gdpr('data-subject')->getByEmail($email);
    if (!$dataSubject->hasConsented('my_custom_consent_slug')) {
      // do your thing!
    }
    

    Let me know if you have additional questions!

    Note that the data subject might not have a user account at all. You can check it like this:

    
    $dataSubject->hasUser()
    
    Thread Starter zittercraft

    (@zittercraft)

    Quick reply, thanks!

    I think I didn’t sleep enough ?? can’t get it work:

    function wc_privacy_consentpopup() { 
      if (is_user_logged_in() ) {
    $current_user = get_currentuserinfo();
    	$email = $current_user->user_email; 
      $dataSubject = gdpr('data-subject')->getByEmail($email);
    if (!$dataSubject->hasConsented('privacy-policy')) {
      // do your thing!
      echo 'Consent given';
      }
      else {echo 'no consent';}
    }}
    add_shortcode( 'wcprivacyconsentpopup', 'wc_privacy_consentpopup' ); 

    The shortcode always returns ‘Consent given’. What did I miss?

    I think you have it backwards:

    
    if (!$dataSubject->hasConsented('privacy-policy')) {
      // do your thing!
      echo 'Consent given';
    }
    

    You’re currently checking if the data subject has NOT given their consent and then echoing “consent given” ??

    Thread Starter zittercraft

    (@zittercraft)

    Yeah, that’s right, my fault. ??

    But, nevertheless: the “else”-echo never shows up. I tried every constellation (logged in, logged out, with given consent, without given consent, if-condition with ! and without).

    Any idea?

    I need the query for users who have yet to give their consent.

    Hmm. Looks like I need to investigate this.
    I cannot do that today, but possibly tomorrow or Saturady.

    Meanwhile, if you could var_dump the $dataSubject object as well as the output of $dataSubject->getConsentData() and let me know if you spot anything weird, that would be helpful.

    Thread Starter zittercraft

    (@zittercraft)

    Great, thanks, I’ll check it out.

    In the meantime I tried this:

    $current_user = get_currentuserinfo();
    	$email = $current_user->user_email; 
      $dataSubject = gdpr('data-subject')->getByEmail($email);
    	
    if (!$dataSubject->hasConsented('privacy-policy')) {
      // do your thing!
      echo 'Consent given by: ';
    echo $email; }

    Same result, no difference between users with and without given consent.

    Here are parts of the output (anonymized, of course). The DataSubject email is correct, but I can’t recognize the “status”-value, so maybe that’s the fault?

    USER without consent

    object(Codelight\GDPR\DataSubject\DataSubject)#9814 (5) { ["email":protected]=> string(19) "[email protected]" ["user":protected]=> object(WP_User)#10146 (8) { ["data"]=> .... 
    ["consentManager":protected]=> object(Codelight\GDPR\Components\Consent\ConsentManager)#1480 (3) { ["model":protected]=> object(Codelight\GDPR\Components\Consent\UserConsentModel)#1483 (3) { ["tableName"]=> string(15) "wc_gdpr_consent" ["version"]=> string(3) "1.0" ["primaryKey"]=> string(2) "id" } ["defaultConsentTypes":protected]=> array(1) { ["privacy-policy"]=> array(4) { ["slug"]=> string(14) "privacy-policy" ["title"]=> string(321) "Die Datenschutzrichtlinie habe ich gelesen und akzeptiere sie." ["description"]=> string(126) "This consent is not visible by default. If someone wishes to withdraw it, they should simply request to delete all their data." ["visible"]=> bool(false) } } ["customConsentTypes":protected]=> array(2) { ["umfrageacceptance"]=> array(4) { ["slug"]=> string(17) "umfrageacceptance" ["title"]=> string(54) "Umfrage." ["description"]=> string(107) "Umfrage eingewilligt" ["visible"]=> string(0) "" } ["faqacceptance"]=> array(4) { ["slug"]=> string(13) "faqacceptance" ["title"]=> string(32) "FAQ" ["description"]=> string(95) "FAQ eingewilligt" ["visible"]=> string(0) "" } } } ["consents":protected]=> array(0) { } ["dataRepository"]=> object(Codelight\GDPR\DataSubject\DataRepository)#10158 (1) { ["email"]=> string(19) "[email protected]" } } Array

    same part, User with given privacy consent
    ["defaultConsentTypes":protected]=> array(1) { ["privacy-policy"]=> array(4) { ["slug"]=> string(14) "privacy-policy" ["title"]=> string(321) "Die Datenschutzrichtlinie habe ich gelesen und akzeptiere sie. " ["description"]=> string(126) "This consent is not visible by default. If someone wishes to withdraw it, they should simply request to delete all their data." ["visible"]=> bool(false) } }

    Thread Starter zittercraft

    (@zittercraft)

    Hi, any news? Would be great!

    Thread Starter zittercraft

    (@zittercraft)

    Pheeow, suddenly it works. I apologize, seems like a bug on my end. I doublechecked, I quadrouplechecked but … sorry for bothering you.

    Keep up the great work!

    No worries! Keep an eye on this and please do let me know if you spot anything else weird. Since you say you checked so many times, it still sounds like there might be something there ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Querying all data subjects who have given a specific consent’ is closed to new replies.