I need to send newsletter X to user Y using PHP.
I am able to get email and user, but when I try to feed that to send
method, nothing happens. When I enabled wp_debug, there is a bunch of notices about “trying to get property of non-object…”, which is related to $user object
The code I’m using:
Newsletter::instance()->send(
Newsletter::instance()->get_email(1),
Newsletter::instance()->get_user('user@example.com')
);
I also tried to get user like that:
Newsletter::instance()->get_user_by_wp_user_id($userid)
but the result is the same.
How can I send specified newsletter to specified user from PHP?