magento2 – How to make checkbox Check/Uncheck onchange trigger event to subscribe/unsubscribe customer from newsletter magento 2 on customer/account?

Basically I have a checkbox on customer/account page adding via code below.

<div class="col-12 col-sm-12">
            <div class="flex-card myaccount-block proofing-block">
                <div class="col-lg-3 float-left">
                <img src="" alt="Automatic Proofing Approval Options" />
                <div class="col-lg-6 float-left">
                    <strong class="box-title">
                        <span><?= $block->escapeHtml(__('Automatic Proofing Approval Options')) ?></span>
                    <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.')) ?>
                        <a href="#" id="proof-learnmore">Learn More..</a>
                <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>
                    <span class="yesno-label">No</span>

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
enter image description here

event sourcing – What are the problems with command handlers returning data in CQRS?

This allows the client to update its representation of the affected resources, without having to perform a follow up query immediately

The catch is in the implication here. What you’re effectively saying is:

I have to fire one less request when I merge the two requests (i.e. the command and subsequent query) into one.

What you’re saying is not wrong, but you are violating the core tenet of CQRS, which it is literally named after: Command Query Responsibility Segregation.

You are correct that merging these two requests saves your frontend a small bit of overhead performance related to the firing and waiting for a second web request (but we can definitely argue about whether this overhead is significant or negligible, which I’ll get into in a bit).

If you’re dealing with a slow network connection, this difference can be non-negligible. e.g. I’ve developed 3G mobile software where network requests were minimized as much as possible due to spotty connections.

However, CQRS isn’t focused on optimizing the performance of the frontend, it’s focused on maintainability and scalability of the backend. This will also benefit the frontend, but in an indirect way. CQRS allows for scalability of your read store (since it is then separated from your write store), thus lowering the overall time of your second request; instead of preventing you from having to fire that second request.

I do want to point out here that for connections with no strict limitations, the cost of performing a second call is negligible and not reasonably spotted by an end user. If there is a noticeable lag due to a second request being fired, on a good connection, that actually suggests that your system should be scaled up (as the requests aren’t being handled in a reasonable time), which is what CQRS helps you with.
If this is the situation you find yourself in, then undoing the command/query segregation is effectively perpetuating your performance issues instead of improving them.

Do you have to use CQRS? Of course not. Just like any other principle or pattern, it exists to fix a particular problem. If the problem doesn’t exist in your scenario (or is not considered a problem), then the principle/pattern is not needed.

But your CQRS “variation” is actually undoing what is essentially the first and only commandment of CQRS: separating your data operations from your data queries.

Does that mean you shouldn’t do what you’re doing? No, not necessarily. But I wouldn’t call it CQRS anymore as it’s quite the opposite.

which possibly would return data from the out-of-date read model, since read models can be updated asynchronously

This is a cart-before-horse situation. If you don’t want to deal with the consequences of having your read store updated asynchronously, then don’t asynchronously update your read store.

It sounds facetious but it really is as simple as that. Asynchronicity has its upsides and its downsides (just like everything), and if you don’t want the downsides, then don’t do it.

Trumps MT Rushmore speech was the Most watched TV event in history?

It was one of the most sickening displays of divisiveness the country has seen. He took a national holiday celebration and turned it into a campaign rally for himself. Bad mouthing everyone but those who support him and barely touching upon the over 130,000 covid deaths in the US since Feb.

You enjoyed it along with other trump suck ups but the world once again saw him for what he is. A lying, dangerous POS.

magento2 – write Jquery event to append text to textbox on checkout page

I am new to Magento 2.
I have a website, in magento2 which offers some products to be add in cart.

On checkout page, I want to append country ISD code to mobile number textbox next to Country dropdown.
For example, if user select Singapore as Country then +63 should be added to mobile number text box, so that user can add his/her mobile number.
So mobile number textbox can have text as +639988776655.

I can achieve this with jQuery, so kindly share where I can write this jquery stuff in magento2 for checkout page.

Any help would be great for me.

drush – My site only listens to the event after I clear all caches

I have a module with an event subscribe that I use to redirect to an age verification page if a cookie is not set, and as long as the current request is not the age verification uri.

if(!isset($_COOKIE('age_gate_ok')) && $request != '/age-verification')
    $welcome = newSymfonyComponentHttpFoundationRedirectResponse("/age-verification");

Problem: the event seems to listen once only, and that is when I use drush to clear cache.
To further explain, I use clear site cache using drush and when I reload the page, it redirects me to the correct page(/age-verification) and then I pass the gate.
However, if I open the inspector to clear cookies and refresh the page, the site does not redirect me to the age verification url.

How do I have to clear cache in order to have the age verification working?

event subscriber – Age verification does not redirect to intended language

I have a multi-lingual site and found an age verification module which am trying to tweak.
If I select the English option, the age gate redirects to the global site as intended. However, if I choose a different language, the site redirects back to the age-gate page.

The submitForm method looks like this:

public function submitForm(array &$form, FormStateInterface $form_state) {

  $age = $this->checkAge($form_state);
  if ($age < 18) {
    setcookie('age_gate_fail', 1, strtotime( '+1 days' ), '/');
    $welcome = newSymfonyComponentHttpFoundationRedirectResponse('');

  } else {

    // Add TRUE to session age_verified.
    $session = Drupal::request()->getSession();
    $session->set('age_verified', 1);

    setcookie('age_gate_ok', 1, strtotime( '+1 days' ), '/');
    setcookie('age_gate_country', $form_state->getValue("country"), strtotime( '+1 days' ), '/');
    setcookie('day', $form_state->getValue("day"), strtotime( '+1 days' ), '/');
    setcookie('month', $form_state->getValue("month"), strtotime( '+1 days' ), '/');
    setcookie('year', $form_state->getValue("year"), strtotime( '+1 days' ), '/');

    if(Settings::get('local_env')) {

      // Add a redirect to requested page. Using $form_state built in redirects.
      $redirect = $session->get('age_verification_path');
      if (!empty($redirect)) {


    } else {

      if($form_state->getValue("language") == 'en') {
      } else {
        $host = Drupal::request()->getHost();
        $welcome = newSymfonyComponentHttpFoundationRedirectResponse("http://$host/{$form_state->getValue("language")}");

The module comes with the EventSubscriber and the content inside is as follows:


* Contains Drupalage_verificationEventSubscriberpathGate.

// Declare the namespace for our own event subscriber.
namespace Drupalage_verificationEventSubscriber;

use SymfonyComponentHttpFoundation;
use SymfonyComponentHttpFoundationRedirectResponse;
use SymfonyComponentHttpKernelKernelEvents;
use SymfonyComponentHttpKernelEventFilterResponseEvent;
use SymfonyComponentEventDispatcherEventSubscriberInterface;
use DrupalCorePathPathMatcherInterface;
use DrupalCoreSessionAccountInterface;
use DrupalCoreRoutingTrustedRedirectResponse;

* Event Subscriber PathGate.
class PathGate implements EventSubscriberInterface {
   * The path matcher.
   * @var DrupalCorePathPathMatcherInterface
  protected $pathMatcher;

   * The current user.
   * @var DrupalCoreSessionAccountInterface
  protected $currentUser;

   * Constructs a new Redirect404Subscriber.
   * @param DrupalCorePathPathMatcherInterface $path_matcher
   *   The path matcher service.
   * @param DrupalCoreSessionAccountInterface $current_user
   *   Current user.
  public function __construct(PathMatcherInterface $path_matcher, AccountInterface $current_user) {
    $this->pathMatcher = $path_matcher;
    $this->currentUser = $current_user;

   * Code that should be triggered on event specified.
  public function onRespond(FilterResponseEvent $event) {
    // The RESPONSE event occurs once a response was created for replying to a request.
    // For example you could override or add extra HTTP headers in here.
    $response = $event->getResponse();

    $session = Drupal::request()->getSession();

    $age_verified = $session->get('age_verified');

    // If we have a valid session.
    if ( $age_verified == TRUE ) {
    if (isset($_COOKIE('age_gate_fail'))) {
      $welcome = newSymfonyComponentHttpFoundationRedirectResponse('');

    // Make sure front page module is not run when using cli (drush).
    // Make sure front page module does not run when installing Drupal either.
    if (PHP_SAPI === 'cli' || drupal_installation_attempted()) {

    // Don't run when site is in maintenance mode.
    if (Drupal::state()->get('system.maintenance_mode')) {

    // Ignore non index.php requests (like cron).
    if (!empty($_SERVER('SCRIPT_FILENAME')) && realpath(DRUPAL_ROOT . '/index.php') != realpath($_SERVER('SCRIPT_FILENAME'))) {

    // Get saved settings and other needed objects.
    $config = Drupal::config('age_verification.settings');

    // Now we need to explode the age_verification_user_agents field to separate
    // lines.
    $user_agents = explode("n", $config->get('age_verification_user_agents'));
    $http_user_agent = Drupal::request()->server->get('HTTP_USER_AGENT');

    // For each one of the lines we want to trim white space and empty lines.
    foreach ($user_agents as $key => $user_agent) {
      // If a user has string from $user_agent.
      if (empty($user_agent)) {
      // To be sure we match proper string, we need to trim it.
      $user_agent = trim($user_agent);

      if ($http_user_agent == $user_agent) {

    // Send to proper page if logged in.
    $skip_urls_config = $config->get('age_verification_urls_to_skip');

    $skip_urls() = '/admin';
    $skip_urls() = '/admin/*';
    $skip_urls() = '/age-verification';
    $skip_urls() = '/user/login';
    $skip_urls() = '/admin/content';

    if (!Drupal::currentUser()->isAnonymous()) {
        $skip_urls() = '/*';

    // Append the urls to skips with some hardcoded urls.
    $skipPaths = $skip_urls_config . "rn" . implode("rn", $skip_urls);

    $request_path = Drupal::service('path.current')->getPath();

    // Check if the paths don't match then redirect to the age verification form.
    $match = Drupal::service('path.matcher')->matchPath($request_path, $skipPaths);
    $is_front = Drupal::service('path.matcher')->isFrontPage();

    // If not the front page then append the requested path alias as a destination parameter.
    if ($is_front == FALSE) {
      $current_uri = Drupal::request()->getRequestUri();
      $destination = '?destination=' . $current_uri;
    } else {
      $destination = '';

    // If the requested path is not restricted.
    if ($match == TRUE) {
    // Redirect to the /age-verification with the destination.
    elseif ($match == FALSE) {

      $redirect = new RedirectResponse('/age-verification' . $destination);


     * {@inheritdoc}
  public static function getSubscribedEvents() {

    $events(KernelEvents::RESPONSE)() = ('onRespond');
    return $events;



How do I fix the redirect to take me to any language I want

8 – Bigpipe after load event

When I enable the bigpipe module most of the blocks disappear, since I use a Vue layer. I’ve tried the following codes but none of them have worked for me:

  var charging_blocs = $('(data-big-pipe-placeholder-id)').length;
  if (!charging_blocs ){
    console.log('This is executed just once, when all bigpipe blocs are loaded');

  var checkReadyState = setInterval(() => {
    if (document.readyState === "complete") {
      console.log('Page is loaded.');
      /* Put your code logic here */
      (function ($, Drupal) {
       console.log('enters here');
      })(jQuery, Drupal);
  }, 100);

Is there a js event on bigpipe to detect that all blocks have been loaded?

event handlers – Build and package app to trigger automated email upon added list item

I am a sharepoint beginner and am looking to create something that will trigger an automated email upon adding a list item to an existing sharepoint list. What should I be creating to help with this (solution/addin/app)? and how should i go about doing so? I am developing with another laptop to build and transfer to another laptop with sharepoint access to deploy. Would it be done through uploading of webpart? if not how would i upload it?

Has to be within sharepoint (sharepoint hosted?)
Unable to install software in sharepoint access computer
I am only a site owner.

How to make an event repeat on the Wednesday following the 3rd Monday of every month in Google Calendar or ical file format?

Is this possible to do in Google Calendar or .ical format?

I’ve explored RRULE options at this site;WKST=MO;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-3