Home Forums Newsletter Plugin Support Automatic add user to list after aprove account

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #308397
    Mark Gerritzen
    Participant

    Hi,

    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 Gerritzen

    #308444
    Stefano
    Keymaster

    After 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).

    #308885
    Mark Gerritzen
    Participant

    Hi 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 Gerritzen

    #308890
    Mark Gerritzen
    Participant

    Hi 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,
    Mark

    #311175
    Mark Gerritzen
    Participant

    Hi Stefano,

    Did you see my message? It is still not working, does no one knows how to solve this issue?

    Kind regards,
    Mark

    #312316
    Anonymous
    Inactive

    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.

    #312355
    Stefano
    Keymaster

    Hi, 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.

    #312916
    Mark Gerritzen
    Participant

    I 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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.