Basically I have a checkbox on customer/account page adding via code below.
app\design\frontend\Company\porto_base_child\Magento_Customer\templates\account\dashboard\info.phtml
<div class="col-12 col-sm-12">
<div class="flex-card myaccount-block proofing-block">
<div class="col-lg-3 float-left">
<img src="/pub/media/images/myaccount/auto-proofing.png" alt="Automatic Proofing Approval Options" />
</div>
<div class="col-lg-6 float-left">
<strong class="box-title">
<span><?= $block->escapeHtml(__('Automatic Proofing Approval Options')) ?></span>
</strong>
<div class="box-content">
<p><?= $block->escapeHtml(__('
By default, once your file is preflighted OK, you will have 1 hour to approve or make changes to your file. If no action is taken within this hour, your order will automatically go into production.')) ?>
</p>
<a href="#" id="proof-learnmore">Learn More..</a>
</div>
</div>
<div class="col-lg-3 float-left">
<span class="yesno-label">Yes</span>
<div class="box-actions">
<label class="proof-switch">
<input type="checkbox">
<span class="slider round"></span></label>
</div>
<span class="yesno-label">No</span>
</div>
</div>
</div>
How can I create a functionality so whenever user check/uncheck this checkbox it will call an observer/controller which will pass the value(customer_email) to Magento backend and change the newsletter subscription status?
I hope I am on the right track of understanding cause this is what I am planning to implement. I am still not sure whether I will need a block or not.
Please, anyone, guide me through this it would be really helpful for me to continue my learning and understand Magento 2. Thank you and cheers. Though I am trying my best to implement this and update here if something relevant