Custom Consent not Saving
-
Hi,
Custom consents are not being saved.
In functions.php, I have the following:-
add_action(‘init’, function() {
gdpr(‘consent’)->register(‘consent-newsletter’,’I want to receive a weekly newsletter from you’);
});This shows up in the dashboard as it should.
In footer.php I have added the following for testing purposes (email address redacted):-
<?php
$dataSubject = gdpr(‘data-subject’)->getByEmail(‘pn*****@***********.com’);
$dataSubject->giveConsent(‘consent-newsletter’);
$consents=$dataSubject->getConsents();
var_dump($dataSubject);
var_dump($consents);
?>This is the output (email address redacted):-
object(Codelight\GDPR\DataSubject\DataSubject)#4795 (5) { [“email”:protected]=> string(25) “pn*****@***********.com” [“user”:protected]=> NULL [“consentManager”:protected]=> object(Codelight\GDPR\Components\Consent\ConsentManager)#267 (3) { [“model”:protected]=> object(Codelight\GDPR\Components\Consent\UserConsentModel)#264 (3) { [“tableName”]=> string(17) “wp_2_gdpr_consent” [“version”]=> string(3) “1.0” [“primaryKey”]=> string(2) “id” } [“defaultConsentTypes”:protected]=> array(3) { [“privacy-policy”]=> array(4) { [“slug”]=> string(14) “privacy-policy” [“title”]=> string(103) “I accept the Privacy Policy” [“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) } [“terms-conditions”]=> array(4) { [“slug”]=> string(16) “terms-conditions” [“title”]=> string(107) “I accept the Terms & Conditions” [“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) } [“consent-newsletter”]=> array(4) { [“slug”]=> string(18) “consent-newsletter” [“title”]=> string(46) “I want to receive a weekly newsletter from you” [“description”]=> NULL [“visible”]=> bool(true) } } [“customConsentTypes”:protected]=> array(0) { } } [“consents”:protected]=> array(0) { } [“dataRepository”]=> object(Codelight\GDPR\DataSubject\DataRepository)#4796 (1) { [“email”]=> string(25) “pn*****@***********.com” } } array(0) { }
EDIT: Having checked the database, the consent data is saving correctly, it is retrieving it that is failing.
- The topic ‘Custom Consent not Saving’ is closed to new replies.