GDPR Consent Field

Jamie Whittingham

Active Member
We are trying to auto add a consent field when ever a new list is created.

I have the field_id = 24 and the 'label' is all working but how do I set the 'value' option for the text we would like to assign to the 'the consent text' field.

I have tried

$model->value = 'blah';

but it does not work.

any ideas please?

thanks
 
@Jamie Whittingham - version 1.5.7 comes with a field specific for gdpr consent.
Yes I understand that - but we are trying to add a ConsentCheckbox by default to all new Lists by editing the source code, so that it becomes mandatory to our customers.
When we do that however the Consent Text is not being added to the ConsentCheckbox field so we just get forwarded to the Update Profile Page with the request to Update the contents. That is of course unacceptable, but even then if you tick the ConsentCheckbox it does not add the Consent Text to the ConsentCheckbox field, so the update is not saved.
So what we need please is the php code to set the "value" of the ConsentCheckbox field to the Consent Text.
 
Yes I understand that - but we are trying to add a ConsentCheckbox by default to all new Lists by editing the source code, so that it becomes mandatory to our customers.
When we do that however the Consent Text is not being added to the ConsentCheckbox field so we just get forwarded to the Update Profile Page with the request to Update the contents. That is of course unacceptable, but even then if you tick the ConsentCheckbox it does not add the Consent Text to the ConsentCheckbox field, so the update is not saved.
So what we need please is the php code to set the "value" of the ConsentCheckbox field to the Consent Text.
@twisted1919 This is the same issue covered in https://forum.mailwizz.com/threads/default-fields-for-new-lists.5151/#post-34030 where you suggested - We could maybe add an option/hook to do this programatically and then instruct you how to do it ?
 
@Jamie Whittingham - there is already a hook in place which can be invoked after a list has been created.
Code:
Yii::app()->hooks->addAction('customer_model_lists_aftersave', function($instance){

    if (time() - strtotime($instance->date_added) > 10) {
         return;
    }

    $type = ListFieldType::model()->findByAttributes(array(
        'identifier' => 'text',
    ));

    if (empty($type)) {
       return;
    }

    $model = new ListField();
    $model->type_id     = $type->type_id;
    $model->list_id     = $instance->list_id;
    $model->label       = 'Whatever';
    $model->tag         = 'WHATEVER';
    $model->required    = 'yes';
    $model->visibility  = 'visible';
    $model->sort_order  = 0;
    $model->save(false);

});
 
Hi mate,

Thanks but that does not resolve the issue.
Code:
$model->label       = 'Whatever';
that works fine but that does not work with MailWizz as you have to also have 'The Consent Text" which your code above does not ruse / set.

We need something like
Code:
$model->value       = 'I give my consent blah blah';

As its the contents of the 'value' attribution that is saved into the field data inside the DB and with your code above, the field is empty which is not accepted nor GDPR compliant.

I hope that makes sense lol

Thanks.
 
I dunno, have a look at how the Consent Checkbox custom field is implemented, all the details are there.
 
@twisted1919

Where would / how would I use the following code sample?

Code:
Yii::app()->hooks->addAction('customer_model_lists_aftersave', function($instance){

   if (time() - strtotime($instance->date_added) > 10) {
        return;
   }

   $type = ListFieldType::model()->findByAttributes(array(
       'identifier' => 'text',
   ));

   if (empty($type)) {
      return;
   }

   $model = new ListField();
   $model->type_id     = $type->type_id;
   $model->list_id     = $instance->list_id;
   $model->label       = 'Whatever';
   $model->tag         = 'WHATEVER';
   $model->required    = 'yes';
   $model->visibility  = 'visible';
   $model->sort_order  = 0;
   $model->save(false);

});
 
Back
Top