Support » Plugin: MailPress » How to send email to mailing list from custom plugin

  • Resolved biaib

    (@biaib)


    Hello.

    I am administrating a wordpress with mailpress and wpadverts.

    I want to send an email to all recepients in adverts_subscribers mailing list (from mailpress) when someone post an add (with the plugin wpadverts).

    My idea was:
    #1 bind to a hook in wpadverts fired when an ad is posted
    #2 generate the email content to be notified
    #3 in the callback, use mailpress to get the mailing list, and send the email with it

    Do you think this is reasonable ? I tried and I am stuck with #3

    See my current code:

    function hello_dolly() {
    	$list = MP_Mailinglist::get_all();
    	printf($list);
    	return;
    }
    
    // Now we set that function up to execute when the admin_notices action is called.
    add_action( 'admin_notices', 'hello_dolly' );

    This fails, with this error:
    Fatal error: Class 'MailPress_mailinglist' not found in /var/www/html/wp-content/plugins/mailpress/mp-includes/class/MP_Mailinglist.class.php on line 105

    Do you have any tips on how I should proceed ?
    I am very new to WordPress, and didn’t do any PHP development in a decade, so please bear with me.

    Cheers,
    Rodolphe

    • This topic was modified 11 months, 3 weeks ago by biaib.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author arena

    (@arena)

    Hi Rodolphe, i have just seen your call for support. i read it and answer you later !

    happy holidays

    Plugin Author arena

    (@arena)

    So here is the answer :

    After analysis, wpadverts relies on post_type and specific taxonomy

    register_post_type( 'advert', ...
    
    register_taxonomy( 'advert_category', 'advert', ...
    

    The best option is not to use mailing list but newsletter.
    Here is the addons, classes and files to add to your existing mailpress. do not forget to save all changes you would make to these files (could be erase do to automatic plugin upgrade).

    Read the .txt file and let me know any changes or else !

    Good tests (not on a live site !)

    https://mailpress.org/post_type/mailpress-wpadverts.zip

    • This reply was modified 11 months, 1 week ago by arena.
    biaib

    (@biaib)

    Hello Arena, thank you so much for your answer, I will try this to see how it works

    Plugin Author arena

    (@arena)

    closed for now

    biaib

    (@biaib)

    Hello,

    I tried installing your plugins, I followed the README but I can’t get to see the post types in the subscriptions settings:

    https://imgur.com/a/G97HJjR

    What could be missing ?

    My steps:

    * copy mp-content and mp-includes in the corresponding mailpress plugin folders DONE
    * copy mp-content/advanced/newsletters content into wp-content/uploads/mailpress/advanced/(blog_id : usually 1 for wp mono-install) DONE
    * add a new file into your current mailpress theme adapted to your needs (see sample in mp-content/themes/_template/advert.php) DONE (I copied it as is, is it enough ?)
    * activate MailPress addon Newsletter DONE
    * activate MailPress addon Newsletter_advert DONE
    * Go to settings > MailPress > Subscription and manage your new post_type newsletter subscriptions MISSING

    Sorry for the very late delay

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.