Home › Forums › Newsletter Plugin Support › Automatic add user to list after aprove account
- This topic has 7 replies, 3 voices, and was last updated 1 year, 9 months ago by
Mark Gerritzen.
-
AuthorPosts
-
October 20, 2023 at 2:44 pm #308397
Mark Gerritzen
ParticipantHi,
I use Ultimate member and the Newsletter plugin, users that register has to be approved by a admin. After that the user should be automaticly added to a certain list, is that possible? Or can I maybe write a script to update the usermeta after approve.
Hope someone can help me,
Kind regards,
Mark GerritzenOctober 22, 2023 at 12:58 pm #308444Stefano
KeymasterAfter approval you should retrieve the subscriber ($subscriber = Newsletter::instance()->get_user_by_wp_user_id(…)) and than change and save the subscriber:
$subscriber->list_4 = ‘1’;
Newsletter::instance()->save_user($subscriber).November 1, 2023 at 12:10 pm #308885Mark Gerritzen
ParticipantHi Stefano,
Sorry for my late reaction I was very busy with other projects. I will try the option you said. Thank you for that, if it won’t work I will come back here.
Kind regards,
Mark GerritzenNovember 1, 2023 at 1:33 pm #308890Mark Gerritzen
ParticipantHi Stefano,
I tried what you said, I also changed your code after finding something in the docs. I used both codes but they give me the same error, see below:
$subscriber = Newsletter::instance()->get_user($user_id);
$subscriber->list_2 = ‘1’;
Newsletter::instance()->save_user($subscriber);Also when I first declare the newsletter as object it isn’t working. You said it had to be get_user_by_wp_user_id() but the documentation says get_user, but both methods work.
I get the following error when approving the user:
Database error. If you were saving a newsletter try a table upgrade from the status panel.I hope you see what’s happening,
Kind regards,
MarkDecember 13, 2023 at 11:40 am #311175Mark Gerritzen
ParticipantHi Stefano,
Did you see my message? It is still not working, does no one knows how to solve this issue?
Kind regards,
MarkJanuary 10, 2024 at 2:29 pm #312316Anonymous
InactiveI get the following error when approving the user:
Database error. If you were saving a newsletter try a table upgrade from the status panel.January 11, 2024 at 7:49 am #312355Stefano
KeymasterHi, try to go to “System/Logs” and check for a “store…txt” file. If not present, set on Newsletter’s main settings the log level to info or error and save again: the log file should be generated with some details.
January 22, 2024 at 12:12 pm #312916Mark Gerritzen
ParticipantI found the bug, it was because of a empty email. If I change the code to:
$subscriber = Newsletter::instance()->get_user_by_wp_user_id($user_id);
$user_data = get_userdata($user_id);$nl_user = array();
$nl_user[‘id’] = $subscriber->id;
$nl_user[’email’] = $user_data->user_email;
$nl_user[‘status’] = ‘C’;
$nl_user[‘list_2’] = 1;Newsletter::instance()->save_user($nl_user);
Than the email is filled in and there will be no error.
Thans for the help,
Mark -
AuthorPosts
- You must be logged in to reply to this topic.