Support » Plugin: MailPoet 2 » 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)
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add / Remove subscriber via PHP’ is closed to new replies.