Skip to:
Content
Pages
Categories
Search
Top
Bottom

Allow Empty “What’s New” Activity Update

  • @creativesinside

    Participant

    We want to allow people to post an empty “what’s new” activity.

    I believe that it uses the built-in wordpress “post” function.

    Therefore I tried this to allow empty posts:

    
    add_filter('pre_post_title', 'wpse28021_mask_empty');
    add_filter('pre_post_content', 'wpse28021_mask_empty');
    function wpse28021_mask_empty($value)
    {
        if ( empty($value) ) {
            return ' ';
        }
        return $value;
    }
    
    add_filter('wp_insert_post_data', 'wpse28021_unmask_empty');
    function wpse28021_unmask_empty($data)
    {
        if ( ' ' == $data['post_title'] ) {
            $data['post_title'] = '';
        }
        if ( ' ' == $data['post_content'] ) {
            $data['post_content'] = '';
        }
        return $data;
    }

    Anyone have any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • @danbp

    Participant

    Please use code button when you post code. Thxs.

    @creativesinside

    Participant

    Ack! My bad … new to the forum!!!

    add_filter('pre_post_title', 'wpse28021_mask_empty');
    add_filter('pre_post_content', 'wpse28021_mask_empty');
    function wpse28021_mask_empty($value)
    {
        if ( empty($value) ) {
            return ' ';
        }
        return $value;
    }
    
    add_filter('wp_insert_post_data', 'wpse28021_unmask_empty');
    function wpse28021_unmask_empty($data)
    {
        if ( ' ' == $data['post_title'] ) {
            $data['post_title'] = '';
        }
        if ( ' ' == $data['post_content'] ) {
            $data['post_content'] = '';
        }
        return $data;
    }

    @shanebp

    Moderator

    I believe that it uses the built-in wordpress “post” function.

    Why would you think that? Even a quick look at the code would show that’s not the case.

    Use this hook:
    apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );

    Try:

    function allow_empty_whatsnew( $content ) {
    	if ( empty( $content ) )
    		$content = ' '; // cannot be empty
    		
    	return $content;
    }
    add_filter('bp_activity_post_update_content', 'allow_empty_whatsnew');
    

    @hnla

    Participant

    The question ought to be what is the user trying to achieve, what id the point of adding an empty content? Tell us why and we might be able to tell you a better or best approach to what you want.

    @creativesinside

    Participant

    Trying to clean up the mess that the other developer created basically. We came up with a different solution.

    Basically we changed What’s New to “About Me” but we wanted to allow for an empty “About Me.”

    We also moved the Activity Stream to a, “My Profile” page and did something very hacky by calling the Activity Stream and hiding everything except for “Delete” and naming that “Clear my About Me.”

    BTW .. I am very new to development. Thanks for helping out.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Allow Empty “What’s New” Activity Update’ is closed to new replies.
Skip to toolbar