WordPress.org

Ready to get started?Download WordPress

Forums

Subscribe2
[resolved] Notifications for customer events? (31 posts)

  1. smithgt
    Member
    Posted 2 years ago #

    Hi,

    I've just installed this plugin and it's just what my site needs as we have multiple editors.

    However, we also use the All in One Event Calendar which I think creates a custom post type.

    Is it possible to have email notification of these events too?

    Thanks

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

  2. mattyrob
    Member
    Plugin Author

    Posted 2 years ago #

    @smithgt,

    Yes it is possible, you'll need to register the custom post type in Subscribe2 as described here. The name of the custom post type seems to be 'ai1ec_event'.

    You may also need to register some custom taxonomy types too, that's covered here. The principle is very similar.

  3. marblez
    Member
    Posted 2 years ago #

    @MattyRob,

    I just googled around to get an answer to my exact question as the one above. But.. I lost you somewhere at "register the custom post type" as I don't have the slightest clue to where this can be added, and that also goes for the custom taxonomy (which I don't even know what it means).

    Could you please explain?

    Thanks in advance and with kind regards,
    Martin

  4. smithgt
    Member
    Posted 2 years ago #

    Thanks MattyRob,

    Silly question, but which PHP file am I to add the my_post_types to?

    subscribe2.php?

    (I've just upgraded to V8)

  5. mattyrob
    Member
    Plugin Author

    Posted 2 years ago #

    @marblez / smithgt,

    Your best bet is to create your own plugin code placed in the wp-content/plugins/ folder that contains the filter code as linked above. If you add it to another plugin file you will lose this with every version update.

  6. smithgt
    Member
    Posted 2 years ago #

    @MattyRob

    While I'm no IT novice, I am new to PHP and wordpress, so I'm a little unsure what I would need to include in a PHP file.

    From your FAQ I beleive that the event type my AI1EC is 'ai1ec_event', so this this script correct?

    /* Code to add post type for AI1EC to Subscribe2 */
    function my_post_types($types) {
    $types[] = 'ai1ec_event';
    return $types;
    }
    add_filter('s2_post_types', 'my_post_types');

    And do I simply drop this in the root folder of /wp-content/plugins or does it need it its own sub folder? Do I have to do anything to activate/ run the code?

  7. mattyrob
    Member
    Plugin Author

    Posted 2 years ago #

    @smithgt,

    That looks about right so far - wrap it in PHP tags and also include a plugin header. Reading here will point you along the right path.

  8. marblez
    Member
    Posted 2 years ago #

    @MattyRob

    Thanks for your replies, but they aren't making me any smarter :-)

    If I would borrow the code smithgt made, and add the things you asked for (php tags), where, what and how would that look?

    What should the .php file be called? And, if I manage to get everything right - how would this line of code work? Would I get a new option in the subscribe2 settings?

    I've never written a single line of php code in my life, so that's why I'm asking :-(

  9. smithgt
    Member
    Posted 2 years ago #

    @MattRob

    OK - I've read that and created this file

    <?php
    /*
    Plugin Name: AI1EC-Subscribe2
    Description: Add AI1EC to Subscribe2 notifications
    Version: 0.1
    Author: smithgt
    */
    ?>
    function my_post_types($types) {
    $types[] = 'ai1ec_event';
    return $types;
    }
    add_filter('s2_post_types', 'my_post_types');

    It's called my_post_types.php and I've uploaded it into my wordpress site into the folder /wp-content/plugins/AI1EC-Subscribe2

    It's now listed under plugins - wow!
    If I activate it I see an error:

    The plugin generated 123 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

    And when I add an event I get this error:

    function my_post_types($types) { $types[] = 'ai1ec_event'; return $types; } add_filter('s2_post_types', 'my_post_types');
    Warning: Cannot modify header information - headers already sent by (output started at /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/AI1EC-Subscribe2/my_post_types.php:13) in /homepages/10/d83518211/htdocs/WordPress/testing/wp-includes/pluggable.php on line 866

    Now I'm a bit stuck :-(

  10. mattyrob
    Member
    Plugin Author

    Posted 2 years ago #

    @smithgt,

    So close - you've closed the PHP tag before your code - move the '?>' to the last line of the file.

  11. smithgt
    Member
    Posted 2 years ago #

    Ah :-)

    Moved that to the end of the file and activation was ok this time around, but when I created a test event I get this error :-(

    Fatal error: Uncaught exception 'Ai1ec_Event_Not_Found' with message 'Event with ID '5752' could not be retrieved from the database.' in /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/all-in-one-event-calendar/app/model/class-ai1ec-event.php:356 Stack trace: #0 /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/all-in-one-event-calendar/app/helper/class-ai1ec-events-helper.php(63): Ai1ec_Event->__construct(5752, false) #1 /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/all-in-one-event-calendar/app/controller/class-ai1ec-events-controller.php(491): Ai1ec_Events_Helper::get_event(5752) #2 [internal function]: Ai1ec_Events_Controller->event_content('<p>bbc</p>?') #3 /homepages/10/d83518211/htdocs/WordPress/testing/wp-includes/plugin.php(170): call_user_func_array(Array, Array) #4 /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/subscribe2/classes/class-s2-core.php(559): apply_filters('the_content', 'bbc') #5 [internal function]: s2class->publish(Ob in /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/all-in-one-event-calendar/app/model/class-ai1ec-event.php on line 356

    It must be something to do with the use of the post type "ai1ec_event" as if I change to something else then the error when posting an event doesnt appear.

    I've asked on the AE1EC forum for confirmation of the post type.

    Does the error mean anything useful to you?

  12. mattyrob
    Member
    Plugin Author

    Posted 2 years ago #

    @smithgt,

    That doesn't mean a great deal to me, it looks like a post with ID 5752 was pushed through that filter as it looked to Subscribe2 as though it was an event but the event plugin could not find it for some reason.

    I wonder if that because you also need to include the custom taxonomies in Subscribe2 as well. It would be additional filters added to your existing code as described here but you'll have to ask for the taxonomy names or dig through the ai1ec code to find them.

  13. smithgt
    Member
    Posted 2 years ago #

    @MattyRob

    I've found some possible taxonomy candidates - events_tags and events_categories

    So how do I add more than one taxonomy? The code below fails :-(

    function my_taxonomy_types($taxonomies) {
    // where 'my_taxonomy_type' is the name of your custom taxonomy
    $taxonomies[] = 'events_tags','events_categories';
    return $taxonomies;
    }
    add_filter('s2_taxonomies', 'my_taxonomy_types');

  14. mattyrob
    Member
    Plugin Author

    Posted 2 years ago #

    @smithgt,

    Like this:

    $taxonomies[] = 'events_tags';
    $taxonomies[] = 'events_categories';
    return $taxonomies;
  15. smithgt
    Member
    Posted 2 years ago #

    @MattyRob

    Thanks, but unfortunately that's still not fixed the AE1EC errors :-(

    Fatal error: Uncaught exception 'Ai1ec_Event_Not_Found' with message 'Event with ID '5778' could not be retrieved from the database.' in /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/all-in-one-event-calendar/app/model/class-ai1ec-event.php:356 Stack trace: #0 /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/all-in-one-event-calendar/app/helper/class-ai1ec-events-helper.php(63): Ai1ec_Event->__construct(5778, false) #1 /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/all-in-one-event-calendar/app/controller/class-ai1ec-events-controller.php(491): Ai1ec_Events_Helper::get_event(5778) #2 [internal function]: Ai1ec_Events_Controller->event_content('<p>test b</p>?') #3 /homepages/10/d83518211/htdocs/WordPress/testing/wp-includes/plugin.php(170): call_user_func_array(Array, Array) #4 /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/subscribe2/classes/class-s2-core.php(559): apply_filters('the_content', 'test b') #5 [internal function]: s2class->publ in /homepages/10/d83518211/htdocs/WordPress/testing/wp-content/plugins/all-in-one-event-calendar/app/model/class-ai1ec-event.php on line 356

  16. mattyrob
    Member
    Plugin Author

    Posted 2 years ago #

    I've had a dig in the event plugin code, this is a thrown error code in one of the files.

    It seems to be saying that the event details are null.

    Now this might be because they are not collected at the time the filter code is called or perhaps they are nit yet created when the filter code is called. I'm not sure. I think it may be better to follow up with the event calendar author as they know their code better.

  17. quadc3
    Member
    Posted 1 year ago #

    Has anyone been able to get these two plugins to work together? I'm very interested in this.

    Thanks!

  18. mattyrob
    Member
    Plugin Author

    Posted 1 year ago #

    @quadc3,

    I'm not aware of any workaround currently but both plugins have gone through some updates since this thread was opened. It might be worth trying them together now to see if the conflict has been ironed out.

  19. quadc3
    Member
    Posted 1 year ago #

    Unfortunately, it doesn't appear to be working. I've been trying for a week to get it to work. Shame. I could really use this functionality.

  20. mattyrob
    Member
    Plugin Author

    Posted 1 year ago #

    @quadc3,

    I've had another brief look at the Event Calender plugin code and I'm not sure that it does use a Custom Post Type as it seems to query another database table for event information.

    Making Subscribe2 work with proprietary third-party data tables is not something that I can spend time developing or supporting if this is indeed the case.

  21. smithgt
    Member
    Posted 1 year ago #

    Thanks for taking a look Mattyrob - I couldn't get it to work either :-(

  22. alexene22
    Member
    Posted 1 year ago #

    Hello,

    I think I got it. It's not straight forward, but for me it works.
    I installed the following plugin: TT Subscribe2 Frontend. This plugin provides a front-end form for the users to manage their subscriptions. In the main php file, there are 3 places indicated by author comments where you can insert custom post types and custom taxonomies. I played a little with these and it worked. The custom post type is "ai1ec_event", and the custom taxonomy is "events_categories", both found in the database.

    Please give it a try and tell me if it works. I'm not an experienced programmer, that's why I bought this small plugin for it's main purpose, but it looks like it helped for other issues too.

  23. mattyrob
    Member
    Plugin Author

    Posted 1 year ago #

    @alexene22,

    Thanks for prompting me :) I've actually got this working too, in a way with Subscribe2 8.5 and AI1EC 1.8.3-premium. Please read right to the end.

    As stated above you need to apply the correct filters to Subscribe2, you've got the right names but the filters above work too. Condensed into a mini-plugin it looks like this:

    <?php
    /*
    Plugin Name: Subscribe2 AI1EC Filters
    Plugin URI: http://subscribe2.wordpress.com
    Description: Adds AI1EC custom post type and taxonomy to Subscribe2.
    Version: 1.0
    Author: Matthew Robinson
    */
    
    function my_post_types($types) {
    	$types[] = 'ai1ec_event';
    	return $types;
    }
    add_filter('s2_post_types', 'my_post_types');
    function my_taxonomy_types($taxonomies) {
        $taxonomies[] = 'events_tags';
    	$taxonomies[] = 'events_categories';
    	return $taxonomies;
    }
    add_filter('s2_taxonomies', 'my_taxonomy_types');
    ?>

    The most important thing of note is that if you enter your new event details and hit Publish you WILL get an error. You MUST save the post as a draft first to create the event calendar database records, then you can hit Publish and it works fine.

    Time.ly are hopefully looking into this to get over this work-around.

  24. Andrew
    Member
    Posted 1 year ago #

    I've read through the entries here, but I'm not sure I've done everything correctly. When I create a new event with AI1EC (Premium) I don't see the box where I can normally check off the "Subscribe2 Notification Override." That's what I need.

    Here's what I did:

    1. Create a folder called located at /wp-content/plugins/AI1EC-Subscribe2
    2. Create a file inside that folder called my_post_types.php
    3. Paste this code inside there:

    <?php
    /*
    Plugin Name: Subscribe2 AI1EC Filters
    Plugin URI: http://subscribe2.wordpress.com
    Description: Adds AI1EC custom post type and taxonomy to Subscribe2.
    Version: 1.0
    Author: Matthew Robinson
    */
    
    function my_post_types($types) {
    	$types[] = 'ai1ec_event';
    	return $types;
    }
    add_filter('s2_post_types', 'my_post_types');
    function my_taxonomy_types($taxonomies) {
        $taxonomies[] = 'events_tags';
    	$taxonomies[] = 'events_categories';
    	return $taxonomies;
    }
    add_filter('s2_taxonomies', 'my_taxonomy_types');
    ?>

    Is that everything? Should I be adding custom post type info or taxonomy info to the TT Subscribe2 Frontend plugin (which I also have installed)? What am I missing?

    Thanks in advance!!!

    -Andrew

  25. Andrew
    Member
    Posted 1 year ago #

    I forgot to add: I activated the plugin "Subscribe2 AI1EC Filters" also. Still no "Subscribe2 Notification Override" box on my New Event custom post type edit page.

  26. quadc3
    Member
    Posted 1 year ago #

    Yeah I couldn't get the custom plugin to work at all, but I found another work around. I just added the code to the Subscribe2.php file itself.

    Basically, I went to Admin Panel -> Plugins -> Editor -> Subscribe2 Drop Down -> and right after the Copyright notice I added just the following:

    function my_post_types($types) {
            $types[] = 'ai1ec_event';
            return $types;
    }
    add_filter('s2_post_types','my_post_types');
    function my_taxonomy_types($taxonomies) {
    $taxonomies[] = 'events_tags';
    $taxonomies[] = 'events_categories';
    return $taxonomies;
    }
    add_filter('s2_taxonomies','my_taxonomy_types');

    Hit Update File. It worked for me.

  27. Andrew
    Member
    Posted 1 year ago #

    Thanks for the tip, but I just followed your directions and, although it didn't result in a fatal error, it didn't add the Subscribe2 Notification Override box to my New Event page.

    Is this what your file looks like? http://screencast.com/t/qwmPxiHnx

    On another forum, a poster said the following:

    @Erling & @basememara,

    In order to add the custom field box to override post notification you have to know the slug name of the added page. It's the fourth parameter passes to the add_meta_box() function.

    For that reason it would be easier to extend the Events plugin to call the Subscribe2 code rather than the other way around. Either that or write your own custom plugin that adds the code to the Events page once you've found the slug name.

    Perhaps the code we're using makes it possible to auto-send an email to subscribers for a new event added, but I need the option to turn it on or off, on a per-post/event basis, like I can do for normal posts. Do you have the notification override option working?

  28. quadc3
    Member
    Posted 1 year ago #

    That's exactly what my code looks like. And no, I don't have the override option working for new events.

    The code we are working with allows for notification emails to be sent out to the categories that people have subscribed to only. If you have everyone subscribed to all categories selected, then, of course, they will get the new posts.

    The only way that I know of around this is to set an excluded category and then tag your event with that category to keep it from going out. Not exactly what you're looking for, but could help prevent spamming your users...

    We keep edging closer to this resolution lol....hopefully, someone else can help you out here.

  29. Andrew
    Member
    Posted 1 year ago #

    Huh, that's an interesting solution. I'll give the excluded category a shot until a better solution pops up. Thanks!!

  30. mattyrob
    Member
    Plugin Author

    Posted 1 year ago #

    @rhdri,

    Further follow up here.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags