WordPress.org

Ready to get started?Download WordPress

Forums

New post notifications when using Custom Post Types (WP 3.0) (9 posts)

  1. illuminateddesigns
    Member
    Posted 4 years ago #

    I'm building a WordPress 3.0 site using custom post types and the subscribe2 plugin:

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

    The plugin sends an email when I create a post using the standard "Post" section of WordPress, but not when I create a new post using the custom post types that I've created, even though they use the same categories that the subscribe2 plugin recognizes and uses.

    Does anybody have any idea how I can get this to work? I can post the code of the Subscribe2 plugin but its quite long, best way is to download it and view subscribe2.php.

  2. illuminateddesigns
    Member
    Posted 4 years ago #

    I feel it has something to do with this section of the plugin. For some reason, it does not recognize the custom post types within the $post variable...or so that's my uneducated guess!

    /**
    	Sends an email notification of a new post
    	*/
    	function publish($post = 0, $preview = '') {
    		if ( !$post ) { return $post; }
    
    		if ( $preview == '' ) {
    			// we aren't sending a Preview to the current user so carry out checks
    			$s2mail = get_post_meta($post->ID, 's2mail', true);
    			if ( (isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no') || strtolower(trim($s2mail)) == 'no' ) { return $post; }
    
    			// are we doing daily digests? If so, don't send anything now
    			if ( $this->subscribe2_options['email_freq'] != 'never' ) { return $post; }
    
    			// is the current post a page
    			// and should this not generate a notification email?
    			if ( $this->subscribe2_options['pages'] == 'no' && $post->post_type == 'page' ) {
    				return $post;
    			}
    
    			// is this post set in the future?
    			if ( $post->post_date > current_time('mysql') ) {
    				// bail out
    				return $post;
    			}
    
    			//Are we sending notifications for password protected posts?
    			if ( $this->subscribe2_options['password'] == "no" && $post->post_password != '' ) {
    					return $post;
    			}
    
    			$post_cats = wp_get_post_categories($post->ID);
    			$check = false;
    			// is the current post assigned to any categories
    			// which should not generate a notification email?
    			foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
    				if ( in_array($cat, $post_cats) ) {
    					$check = true;
    				}
    			}
    
    			if ( $check ) {
    				// hang on -- can registered users subscribe to
    				// excluded categories?
    				if ( '0' == $this->subscribe2_options['reg_override'] ) {
    					// nope? okay, let's leave
    					return $post;
    				}
    			}
    
    			// Are we sending notifications for Private posts?
    			// Action is added if we are, but double check option and post status
    			if ( $this->subscribe2_options['private'] == "yes" && $post->post_status == 'private' ) {
    				// don't send notification to public users
    				$check = true;
    			}
    
    			// lets collect our subscribers
    			if ( !$check ) {
    				// if this post is assigned to an excluded
    				// category, or is a private post then
    				// don't send public subscribers a notification
    				$public = $this->get_public();
    			}
    			$post_cats_string = implode(',', $post_cats);
    			$registered = $this->get_registered("cats=$post_cats_string");
    
    			// do we have subscribers?
    			if ( empty($public) && empty($registered) ) {
    				// if not, no sense doing anything else
    				return $post;
    			}
    		}
  3. mattyrob
    Member
    Posted 4 years ago #

    Version 5.9 allows for custom post types to be filtered into Susbcribe2 via and API.

  4. Fanaticweb
    Member
    Posted 3 years ago #

    No it does not Matty, even adding it through the admin panel manually when posting an article doesn't do the job, same thing happens with another Plugin that used to work marvelously: Post Notification. Ever since the custom_post integration in WP 3.0, it no longer recognises the custom_posts categories, just the default Blog posts, which is truly sad, it was a great Plugin.

  5. ko_chin
    Member
    Posted 3 years ago #

    Anyone manage to get this working? I have a similar issue.

  6. ko_chin
    Member
    Posted 3 years ago #

    Nevermind, I figured it out... you just need to add the custom post types to the array.. in case anyone else needs it:

    if ( $this->subscribe2_options['pages'] == 'yes' ) {
    $s2_post_types = array('page', 'post', 'YOUR CUSTOM POST');
    } else {
    $s2_post_types = array('post', 'YOUR CUSTOM POST');
    }
    $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
  7. Fanaticweb
    Member
    Posted 3 years ago #

    NO WAY!??! I'm gonna try this on a demo site, if it works, I'm sending YOU a donation for that!

  8. Fanaticweb
    Member
    Posted 3 years ago #

    Argh! Totally mixed things up, I thought this was used on the Post Notification plugin, I liked that one more given it actually displayed a list of the categories and sub-categories that the user can subscribe to, I'll try it out on the Subscribe2 plugin for the heck of it...

  9. Fanaticweb
    Member
    Posted 3 years ago #

    Ouff! I went into the Options.php file and added the following while my custom_post type is "ad_category" used by the theme I installed, at least thats the permalink prefix of the custom posted ad:

    if ( $this->subscribe2_options['pages'] == 'yes' ) {
    $s2_post_types = array('page', 'post', 'ad-category');
    } else {
    $s2_post_types = array('post', 'ad-category');
    }
    $s2_post_types = apply_filters('s2_post_types', $s2_post_types);

    Didn't work for me :(
    Wondering if the custom post I'm using is not correct or is something else wrong in the script?

    Help?

Topic Closed

This topic has been closed to new replies.

About this Topic