Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/01/2016 07:24:50 AM (4 years ago)
Author:
johnjamesjacoby
Message:

Favorites/Subscriptions/Moderators: Introduce metadata API for linking multiple users to multiple forums/topics.

Previous to this, connections were stored in usermeta. We knew this would not scale, but bbPress 1 had a friendlier database schema & we expected WordPress's taxonomy/relationship roadmap would be farther along by now.

By storing user ID's in postmeta instead, we gain an ability to query for connections from both directions without custom MySQL, while also leveraging persistent caching in a more sane way.

This commit includes several new helper functions for low-level relationship management, as well as modifications to existing functions to allow them to continue to work as they always have.

See: #2959.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/capabilities.php

    r6056 r6109  
    812812 */
    813813function bbp_add_moderator( $object_id = 0, $user_id = 0 ) {
    814     return add_post_meta( $object_id, '_bbp_moderator_id', $user_id );
     814    return bbp_add_user_to_object( $object_id, $user_id, '_bbp_moderator_id' );
    815815}
    816816
     
    826826 */
    827827function bbp_remove_moderator( $object_id = 0, $user_id = 0 ) {
    828     return delete_post_meta( $object_id, '_bbp_moderator_id', $user_id );
     828    return bbp_remove_user_from_object( $object_id, $user_id, '_bbp_moderator_id' );
    829829}
    830830
     
    839839 */
    840840function bbp_get_moderator_ids( $object_id = 0 ) {
    841     return get_post_meta( $object_id, '_bbp_moderator_id', false );
     841    return bbp_get_users_for_object( $object_id, '_bbp_moderator_id' );
    842842}
    843843
Note: See TracChangeset for help on using the changeset viewer.