You can construct a link for your newsletters and mailings that allow users to suscribe newsletter. Also you can create a button in your ajax call and set optin:


¡No te pierdas la fiesta! Pulsa este botón para que te informemos de las mejores experiencias, eventos, novedades… ¡y mucho más!


public function optin() {
    if (Identity::isConnected() && ('false' === UserApi::getUserLoggedConsumerOptin())) {
        $url = str_replace('edit_account_input', 'optin', OAuthConfig::getEndpointUrl('edit_account_endpoint'));

        $params = array(
            'code' => UserApi::getUserLoggedOid(),
            'e' => env('PROMOCION_CENA'),
            'accept' => 'true'

        $response = \Genetsis\core\Request::execute($url, $params, \Genetsis\core\Request::HTTP_GET, \Genetsis\core\Request::NOT_SECURED);


        if (isset($response['meta'], $response['meta']['response_header']) && (strpos($response['meta']['response_header'], '/optin_success') !== false)) {
            return "Tus datos han sido actualizados, muchas gracias";
        } else {
            Log::error('error calling optin method');
    } else {
        Log::debug('user is not logged or optin is true-> connected');

    return "¡ups! parece que algo ha ido mal y no hemos podido actualizar tus datos. Inténtalo más tarde";

Endpoint URL:

 GET https://{}/register/optin

Request parameters

To create the optout link, you have to construct a URL with the following GET parameters:

codeObject ID of the user to be unsubscribed from receiving communications.stringyes
eEntrypoint key where the request is being made. If you send this params, DruID will show buttons that redirect user to ‘App url’ if user cancel the optout, or once the process optout is completed.stringno, but it is always desirable to send it