Support » Plugin: MailPoet Newsletters » Add / Remove subscriber via PHP

  • Resolved ceruleus

    (@ceruleus)


    Hi there. I would like to know how can I add / remove user to the subscribers list?
    I looked at the examples here and made some function which I call after verifying data of the whole form. I tried to find some reference manual, to see which method is for what and which objects are for what, but without success.
    One more thing – I will need one function for removing the user – but I have no idea how to do that since I don’t know which method is for what (and what methods are existing).

    Here is my function:

    function processMyWysija($idTmp){
    	// $idTmp is id of WP user - it's successfully passed here.
    	$idTmp = intval($idTmp);
    	$userData = get_userdata($idTmp);
    
    	$dataList=array('name','list_id');
    	$modelList = &WYSIJA::get('list','model');
    	$wysijaLists = $modelList->get($dataList);
    	$arrlist = array();
    	foreach($wysijaLists as $list){
    		$arrlist[] = $list['list_id'];
    	}
    
        $udata=array(
            'email'=>$userData->user_email,
            'firstname'=>$userData->first_name,
            'lastname'=>$userData->last_name,
    		);
    
        $data=array(
          'user'=>$udata,
          'user_list'=>array('list_ids'=>$arrlist)
        );
    
        $userHelper=&WYSIJA::get('user','helper');
        print_r($userHelper); // here I expected some methods or something, only I got is WYSIJA_help_user Object ( ).
        $userHelper->addSubscriber($data);
    }

    Any help is appreciated. Thanks in advance!

    http://wordpress.org/extend/plugins/wysija-newsletters/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Sorry, I forgot to say the main thing -_-‘ This function DOESN’T work. There is no any PHP error, or some echoed / printed error. Just, this function doesn’t add an user to a list.

    Well you need to hook that function so that it gets triggered.
    It’s all in that guide : http://support.wysija.com/knowledgebase/plugin-form-integrate/

    The hook is something like that : add_action(‘init’,’processMyForm’);

    Ben

    Do you know how to remove subscribers without php? I’m using WordPress 3.5.1 don’t believe I’m using a plugin for subscribers. Any ideas?

    Thanks!

    Plugin Author MailPoet

    (@wysija)

    Jack, you’re trying to remove or delete Wysija subscribers?

    You can do that directly in the plugin. Look for the batch actions in the drop down menu.

    Thanks for your reply. It’s not in the wysija plugin, it’s through JetPack Blog Subscriptions. Any ideas?

    Thanks ahead of time!

    amistad18

    (@amistad18)

    Jack, if you were gathering your subscribers through JetPack, then you should ask your question here:
    http://wordpress.org/support/plugin/jetpack

    Hello ceruleus,

    Did you find the way to add subscriber with a hook (and make it working !)?
    I just need to affect a subscriber to a specific list and would like to know what’s the best code for this.
    Thanks
    Pat

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add / Remove subscriber via PHP’ is closed to new replies.