I have a situation where im using a plugin for inviting friends (using Facebook) to my website. I want to attach an action at the end of the invite … I want to subscribe the user (which is already logged in since the invite system functions only for logged in users) on the subscribers list adding even an preference for that user so i can better target the group of users, lets say i put the preference name “Premium”.
So the idea is to create in incentive system for the users to invite their friends to become members of my website and at the end of the invite i subscribe automatically these users to a premium list. Since Newsletter does not have lists management but it uses preferences to target lists i want to do that.
How to add the users programatically to the subscribers list?
You should try to build an associative array with the data and then call Newsletter::instance()->save_user($user). $user must contain at least the email address under the ’email’. Anyway the field names and the wp_newsletter columns names.