This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Extensions » One single form for User website...

One single form for User website registration and User newsletter subscription

One single form for User website registration and User newsletter subscription

Friday 23 May 2014 6:55:01 pm - 5 replies


I am really pleased to use the CJW Newsletter extension.

To simplify the user subscription to the newsletter, I would like to merge the newsletter/subscription under the user/register page. Actually, the user has 2 different forms to manage his details: that's not really user friendly.

At this stage, I try to remove the use of the newsletter subscription and manage this through a trigger + workflow. But what I see in the newsletter/subscribe.php let me think that's tricky.

Any idea or advice on it?

Thanks in advance.

Modified on Friday 23 May 2014 9:05:34 pm by Senor Zorro

Friday 23 May 2014 9:39:18 pm

You could use an EditHandler and inject the newsletter subscription functionality on the registration form in one step, just put the subscribe API call into the EditHandler's store / publish function.

But be aware of garbage collection if user does not finish registration....

Saturday 24 May 2014 12:13:06 pm

Hi Arthur,

That's a good idea!

Did you ever use this method on the user/registration form?
I am not sure how to deal with that.

Thank you for your feedback.

Modified on Saturday 24 May 2014 12:41:57 pm by Senor Zorro

Monday 26 May 2014 10:40:26 am

If you are talking about ezpublish 4.x then you should have a new datatype called "newsletter" after installing CJW newsletter which you can add it to your user class and everything would be done automatically by that. [if the user selects that, then he/she would be added automatically to subscribers too.]

was it an answer to your question ?


P.S: this is one of the best extensions ever.

Modified on Monday 26 May 2014 10:40:56 am by Amir Koklan

Wednesday 28 May 2014 6:01:27 pm

Hi Amir,

Thanks a lot for your reply. The datatype is really obvious! Unfortunately, it is not really documented.

I added this datatype in my user class.

Unfortunately, I got an issue with this CjwNewsletterSubscriptionType.

Now, when a new user regiter the website I got an error when the user activate his account.

The new user receive his validation email (from user/register.php), click on the activation link, and then the website display the following error (with XDebug on my dev):

( ! ) Notice: Undefined index: list_output_format_array in C:\ez_shopping\extension\cjw_newsletter\classes\cjwnewslettersubscription.php on line 669Call Stack#TimeMemoryFunctionLocation10.0056708560{main}( )..\index.php:020.12948246728eZModule->run( )..\index.php:72330.12998263016eZProcess::run( )..\ezmodule.php:155240.12998263224eZProcess->runFile( )..\ezprocess.php:2150.13088302680include( 'C:\ez_shopping\kernel\user\activate.php' )..\ezprocess.php:4660.170012713536eZOperationHandler::execute( )..\activate.php:5970.172712956488eZModuleOperationInfo->execute( )..\ezoperationhandler.php:5780.175013007552eZModuleOperationInfo->executeBody( )..\ezmoduleoperationinfo.php:21690.177713106288eZModuleOperationInfo->executeClassMethod( )..\ezmoduleoperationinfo.php:529100.177913106704call_user_func_array ( )..\ezmoduleoperationinfo.php:807110.177913106888eZUserOperationCollection->publishUserContentObject( )..\ezmoduleoperationinfo.php:807120.178013107248eZOperationHandler::execute( )..\ezuseroperationcollection.php:208130.183813705488eZModuleOperationInfo->execute( )..\ezoperationhandler.php:57140.184813707168eZModuleOperationInfo->executeBody( )..\ezmoduleoperationinfo.php:216150.302016380120eZModuleOperationInfo->executeClassMethod( )..\ezmoduleoperationinfo.php:529160.302216380584call_user_func_array ( )..\ezmoduleoperationinfo.php:807170.302216380816eZContentOperationCollection->attributePublishAction( )..\ezmoduleoperationinfo.php:807180.339516876856eZContentObjectAttribute->onPublish( )..\ezcontentoperationcollection.php:191190.343817006056CjwNewsletterSubscriptionType->onPublish( )..\ezcontentobjectattribute.php:729200.358217595176CjwNewsletterSubscription::createSubscriptionByArray( )..\cjwnewslettersubscriptiontype.php:226

After tracking the trace, the CjwNewsletterSubscription->onPublish () receive the subscription_data_array without any subscription information (id_array is empty, list_array is empty and list_output_format_array is undefined).

Here's the $dataArray in onPublish():

  [is_new_object_draft] => 1
  [subscription_data_array] => Array
  [ez_user_id] => 6264
  [email] =>
  [salutation] => 1
  [first_name] => Fabien
  [last_name] => Scantamburlo
  [id_array] => Array
  [list_array] => Array
  [existing_newsletter_user] =>


In the database,

- the cjwnl_user exists, but not confirmed (whereas the activation mail is validated)
- the cjwnl_subscription does not exists.

Any idea?


Modified on Wednesday 28 May 2014 6:03:36 pm by Senor Zorro

Friday 30 May 2014 3:46:49 pm


I think I found out the reason. In fact, there are 2 reasons.

In cjwnewslettersubscriptiontype.php, the default $subscriptionDataArr is missing the default ['list_outpur_format_array']=>array(). This will fix the notice error. The second error is because $contentObject->attribute( 'is_published' ) is undefined and returns false... So with the first user publication, we are in the case where the user is $isNewObjectDraft (version 1 and unpublished)...

May be that will help.

Modified on Friday 30 May 2014 3:47:22 pm by Senor Zorro


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from