WordPress.org

Ready to get started?Download WordPress

Forums

Subscribe2
Custom emails sending schedule by category (11 posts)

  1. Trashmoutarde
    Member
    Posted 2 years ago #

    Fisrt of all : sorry for my english, it's not my primary language... I'll try to make it sound good ;)

    As recommended on the plugin's blog I've already tried to find an answer in the ReadMe and looked through the FAQs...

    We're having Subscribe2 running on a collaborative WordPress/BuddyPress site where a lot of posts (and consequently a lot of categories) are written everyday. We would like to set a "For each post" send for one category and a weekly digest for all the others.

    Is there an easy way to achieve this ?
    Quick newbie Brainstorm :
    -Install two concurents instances of subscribe2 ?
    -Subscribe2 + another plugin ? one plugin "for each post" and one for digest... ideas, suggestions of plugins ?
    -Subscribe2 code modifications ? (need help on this one)

    I'll do my best to understand technical answers as I'm quite new to the WordPress platform, so I may not be (yet) familiar to the files and code structure behind it (I'm at ease with PHP).

    Thanks in advance :)

    http://wordpress.org/extend/plugins/subscribe2/

  2. mattyrob
    Member
    Plugin Contributor

    Posted 2 years ago #

    @Trashmoutarde,

    I've never tried this but I think your best way would be to have two instances of Subscribe2. You'll need to make some code edits though to avoid conflicts.

    Subscribe2 operates as a class so to a degree all the code runs in it's own little world. This world is called $mysubscribe2. If you had 2 folders in the wp-content/plugins folder (one called subscribe2 and once called subscribe2_digest for example) then in one of those you'll need to change the name of the 'world' to keep the 2 instances of the 'worlds' separate.

    I think you would only need to make that change in the main subscribe2.php file unless you are running a multisite version of WordPress.

    Then configure each to your specifications above and see if it works!

  3. Trashmoutarde
    Member
    Posted 2 years ago #

    Thanks for the quick answer.

    I've tried your option and it seemed to work at first... Having 2 instances at the same time is now ok, they are sending 1 email each for every new post. I only have to find a way to make them behave differently. Changing the settings in wp-admin is irrevelant due to the fact that it modifies them for both instances... wich then behave the same way ;) The menu is also duplicated, but that's the kind of "glitch" I can live with.

    Here is what I've donne so far :

    -Installed subscribe2

    -Copied the directory of subscribe2 and renamed the copy subscribe2_digest

    -In "subscribe2_digest/subscribe2.php" :
    Modified "Plugin Name: Subscribe2" by "Plugin Name: Subscribe2_digest"
    Modified "$mysubscribe2" by "$mysubscribe2_digest"

    -In "subscribe2_digest/include/options.php" :
    modified all the occurences of "if (!isset($this->subscribe2_options['OPTION_NAME']))" by "if (!isset($this->subscribe2_options['digest_OPTION_NAME']))" so that the variable "subscribe2_options['digest_OPTION_NAME']" will logically not be set and therefore i could hardcode the settings I want for this instances directly in the "options.php" file.

    This try to make them behave differently failed...

    Do you have any other ideas ?

  4. mattyrob
    Member
    Plugin Contributor

    Posted 2 years ago #

    @Trashmoutarde,

    Of course the options! I had not considered that.

    Your renaming of the folder and change of the class variable is great. I'd suggest you revert all the changes to the options.php file and then look for the instances of:
    update_option('subscribe2_options', $this->subscribe2_options);

    And change this to:
    update_option('subscribe2_digest_options', $this->subscribe2_options);

    There are 5 instances you need to find, 3 in classes/class-s2-core.php, 1 in classes/class-s2-admin.php and 1 in admin/settings.php.

    That will ensure you create a different set of options for the digest code. Then you need to make sure the plugin uses this new set of options by replacing:
    get_option('subscribe2_options')

    in the classes/class-s2-core.php file with:
    get_option('subscribe2_digest_options')

  5. Trashmoutarde
    Member
    Posted 2 years ago #

    @MattyRob

    Thanks again for your help, I've tried something like that (about the options) this afternoon, way much complicated my way so I applied your recommended changes.

    But the results are the same, everything is ok if only one out of two subscribe2 plugin is "enabled" no matter wich of the two (digest or not) it will use the right settings. When both of them are enabled, both use the the "subscriber2" settings, the "subscriber2_digest" settings are completely bypassed (according to the "mailtext" option value I used to differenciate the emails during testing).

    No matter the enabling order (digest before genuine) the settings used are those in the "subscriber2_options" of the "wp_options" table in the database when both instances are enabled.

    When only "subscriber2_digest" is enable, it uses the "subscriber2_digest_options" of the "wp_options" table in the database.

    Could it be wordpress that can't manage options for the two instances at a time ? Is there a kind of global "option mamager" in wordpress that stores all enabled plugins options and where the options of the two instances could overwrite each other ?

  6. mattyrob
    Member
    Plugin Contributor

    Posted 2 years ago #

    @Trashmoutarde,

    I have not actually implemented or tried any of my suggestions so I'm looking as this from a purely theoretical basis. I can't imagine why WordPress wouldn't respect the different option names. I'll have to have a think and get back to you if anything else comes to mind.

  7. Trashmoutarde
    Member
    Posted 2 years ago #

    Ok, i'll be thinking and testing on my side to try to get rid of this problem. I'll keep you updated here about any progress, in hope you'll do the same if anything that could help me comes to your mind ;)

  8. mattyrob
    Member
    Plugin Contributor

    Posted 2 years ago #

    @Trashmoutarde,

    Okay, I think the issue is to do with the way the menus are added and processed.

    If you have one instance of Subscribe2 the menus have a slug of 's2'. I edited the digest duplicate code to have a slug of 's2d' but then when 2 instances of the plugin are active, for some reason the menus are duplicated under one slug heading rather than being kept as separates.

    Even more bizarre, if you copy the code for one set of menus into the other plugin, this then works and the menus are kept individual!

  9. mattyrob
    Member
    Plugin Contributor

    Posted 2 years ago #

    @Trashmoutarde,

    Okay, a bit more. In the subscribe2.php file there are several constants defined like S2URL and S2PATH but these will only exist once for both instances of the plugin. These need turning into class variables like $this->S2DIR and then all instances where these are used will need changed too.

    This is going to prove very difficult to implement in a way that makes upgrades easy. Perhaps it might be wise to look at using 2 similar plugins instead.

  10. Trashmoutarde
    Member
    Posted 2 years ago #

    @MattyRob

    I've been forced to halt my testing on the subject covered here for some times... I'm back on it now.

    Thanks for your last answers.

    This is going to prove very difficult to implement in a way that makes upgrades easy. Perhaps it might be wise to look at using 2 similar plugins instead.

    Due to this conclusion, and to the fact that we did not find any other plugin that could do the trick, my employer (I'm working for a university) is asking me to ask you if a donation could be considered for you to incorporate a "mode" where each post category could be associated with it's own email sending schedule (already existing immediate and digest options are ok). With this kind of custom email sending schedules by category, there is no more need for two instances of the plugin.

    As they say : it can't hurt to ask ;)

  11. mattyrob
    Member
    Plugin Contributor

    Posted 2 years ago #

    @Trashmoutarde,

    I'm not a full time web developer - I do this in my limited spare time so sadly I cannot undertake the implementation of these features. Try making a posting on the WordPress Jobs pages.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags