WordPress.org

Ready to get started?Download WordPress

Forums

MailPoet Newsletters
[resolved] Add / Remove subscriber via PHP (8 posts)

  1. ceruleus
    Member
    Posted 1 year ago #

    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/

  2. ceruleus
    Member
    Posted 1 year ago #

    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.

  3. Ben
    Member
    Plugin Author

    Posted 1 year ago #

    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

  4. JackWisdom
    Member
    Posted 1 year ago #

    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!

  5. MailPoet Staff
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  6. JackWisdom
    Member
    Posted 1 year ago #

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

    Thanks ahead of time!

  7. amistad18
    Member
    Posted 1 year ago #

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

  8. poco06
    Member
    Posted 7 months ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic