Support » Plugin: Content Update Notification » Notification for custom post type

  • Resolved dcgavril

    (@dcgavril)


    Hi,

    First of all thanks for your work on the Content Update Notification plugin.
    I have a site that uses custom post types through CMB2 – https://wordpress.org/plugins/cmb2/
    Is there any way to get notified when a custom post like that gets modified ? and maybe even the actual changes ?!? (currently you can see the change in the post history, but it’s not available for cus )
    I’ve seen that you have answered someone else’s question with a custom code, but imagine a website where you have 20+ custom post types, and adding more every week, so there should be a way to see all the custom post types directly and update that list dynamically.

    Thanks again.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andrew Norcross

    (@norcross)

    Yes. you can use the cun_content_types filter. Currently the default is posts and pages, and the standard way would be to add them. But if you’re adding numerous custom post types (which is odd, but that’s neither here nor there) you would want to get a list of them by using the get_post_types function (using whatever criteria fits your need) and then feeding that into the function.

    https://codex.wordpress.org/Function_Reference/get_post_types

    Here’s an example.

    
    function rkv_add_cun_type( $types ) {
    
    	// Get a list of all the available post types.
    	$list   = get_post_types( '', 'names' );
    
    	// Loop the names and add to the array.
    	foreach ( $list as $single_type ) {
    
    		// Check for the post type, then add it.
    		if ( ! in_array( $single_type, $types ) ) {
    			$types[] = $single_type;
    		}
    
    	}
    
    	// Return the post type array.
    	return $types;
    }
    
    add_filter( 'cun_content_types', 'rkv_add_cun_type' );

    Thanks for your quick reply.

    But that’s not ok with all the custom types and metaboxes/fields, it’s going to go crazy and send hundreds of emails for a simple field change…

    I’ll try to find out another solution related to your idea.

    PS: the custom post types are useful for directories, and there you need multiple post types (there will not be too many(as stated above), because we also use categories and specific fields based on the categories and post types)

    Plugin Author Andrew Norcross

    (@norcross)

    Well, is there some way you can pull a list of the post types that are set up the way you want? However you can get an array of the post types you want to have set up, feed that into the function above.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Notification for custom post type’ is closed to new replies.