WordPress.org

Ready to get started?Download WordPress

Forums

WordPress MU Sitewide Tags Pages
[resolved] SWT and p2 -Status Updates (8 posts)

  1. valuser
    Member
    Posted 1 year ago #

    Is there any way to prevent p2 "Status Updates" from being sent to the SWT tags blog?

    Think status updates are a type "post format" ?

    At the moment they are been picked up by the tags blog. a pretty cool plugin!

    Would prefer a global control as p2 is mainly front-end.

    http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/

  2. valuser
    Member
    Posted 1 year ago #

    OK!

    almost there but need a little help. Please!

    Picked this up on buddypress forums and and adapted it for SWT; seems to work for excluding tags.

    its just now i need to exclude a defined post_format !

    function youdo_not_record_this_tag( $post_id, $post ){
    
    	/* this is the array that contains the tag to exclude */
    	$tag_slugs_to_exclude = array( '999' );
    
    	if ( 'publish' != $post->post_status )
    		return false;
    
    	$post_tags = get_the_tags( $post_id );
    	$in = false;
    
    	if( !empty( $post_tags ) ) {
    
    		foreach ( $post_tags as $post_tag ) {
    			if( in_array( $post_tag->slug, $tag_slugs_to_exclude ) )
    				$in = true;
    
    		}
    
    		/* if the post has at least one excluded tag, then we remove the SWT hook that records an activity */
    		if( $in )
    			remove_action( 'save_post', 'sitewide_tags_post', 10, 2 );
    
    		}
    
    }
    
    add_action( 'sitewide_tags_allowed_post_types', 'youdo_not_record_this_tag', 9, 2);

    the above appears to exclude psts with a 999 tag.

    Just need exclusion for post_format.

    Any ideas very welcome

  3. valuser
    Member
    Posted 1 year ago #

    no dice. Incorrect. The above stops everything ! Not of use

  4. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 1 year ago #

    P2 status updates have a category attached (vs being post formats).

    I would hook into save_post at priority 9 and check the categories on the post. If it has a category that signals a P2 post that you don't want copied then add a filter (not an action) to sitewide_tags_allowed_post_types and remove the 'post' post type.

  5. valuser
    Member
    Posted 1 year ago #

    Thanks again.

    status-update is cat 1

    Tried this (below)- but it leaves everything through and have searched.

    a search for
    sitewide_tags_allowed_post_types save_post just six entries 3 arethe svn or a copy of plugin.

    function ado_not_record_this_category( $post_id, $post ){
    
    	/* this is the array that contains the category to exclude */
    	$ids_to_exclude = array( 1,18 );
    
    	if ( 'publish' != $post->post_status )
    		return false;
    
    	$categories = get_the_category( $post_id );
    	$in = false;
    
    	if( count($categories) > 0 ) {
    
    		foreach ( $categories as $category ) {
    
    			if( in_array( $category->cat_ID, $ids_to_exclude) )
    				$in = true;
    
    		}
    
    		/* if the post has at least one excluded category, then we try to remove the SWT hook that records an activity */
    		if( $in )
    			remove_action( 'save_post', 'sitewide_tags_allowed_post_types', 9, 2 );
    
    	}
    
    }
    
    add_filter( 'sitewide_tags_allowed_post_types ', 'ado_not_record_this_category', 9, 2 );

    Any help GREATLy appreciated

  6. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 1 year ago #

    remove_action( 'save_post', 'sitewide_tags_allowed_post_types', 9, 2 );

    That doesn't work because the save_post hook is already in process when you remove the action. What I meant was change

    add_action( 'sitewide_tags_allowed_post_types', 'youdo_not_record_this_tag', 9, 2);

    to

    add_action( 'save_post', 'youdo_not_record_this_tag', 9, 2);

    then if you match

    add_filter( 'sitewide_tags_allowed_post_types', 'some_function' );

    and in some_function remove the 'post' post type.

  7. valuser
    Member
    Posted 1 year ago #

    Thanks Ron. Eventually followed your instructions correctly! Chuffed. Works!

  8. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 1 year ago #

    You're welcome.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags