Skip to:
Content

bbPress.org

Changeset 6917


Ignore:
Timestamp:
11/05/2019 08:10:34 PM (2 years ago)
Author:
johnjamesjacoby
Message:

Anonymous: delete meta key if value is empty.

This commit ensures that editing a non-anonymous topic via WordPress Admin does not erroneously add empty anonymous author keys to post meta.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r6916 r6917  
    646646    // Update all anonymous metas
    647647    foreach ( $r as $anon_key => $anon_value ) {
    648         update_post_meta( $post_id, '_' . $anon_key, (string) $anon_value, false );
     648
     649        // Update, or delete if empty
     650        ! empty( $anon_value )
     651            ? update_post_meta( $post_id, '_' . $anon_key, (string) $anon_value, false )
     652            : delete_post_meta( $post_id, '_' . $anon_key );
    649653    }
    650654}
Note: See TracChangeset for help on using the changeset viewer.