Skip to:
Content

bbPress.org

Changeset 6517


Ignore:
Timestamp:
06/10/2017 08:10:32 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Introduce bbp_remove_user_from_all_objects().

This is useful for when a user is permanently deleted, or when all of their relationship(s) (of a certain type) need to be removed.

See #3068.

File:
1 edited

Legend:

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

    r6515 r6517  
    5757    // Filter & return
    5858    return (bool) apply_filters( 'bbp_remove_user_from_object', (bool) $retval, $object_id, $user_id, $meta_key, $meta_type );
     59}
     60
     61/**
     62 * Remove a user id from all objects
     63 *
     64 * @since 2.6.0 bbPress (r6109)
     65 *
     66 * @param int    $object_id The post id
     67 * @param int    $user_id   The user id
     68 * @param string $meta_key  The relationship key
     69 * @param string $meta_type The relationship type
     70 *
     71 * @uses delete_post_meta() To remove the term from the object
     72 * @uses apply_filters() Calls 'bbp_remove_user_from_object' with the object
     73 *                        id, user id, and taxonomy
     74 * @return bool Returns true is the user taxonomy term is removed from the object,
     75 *               otherwise false
     76 */
     77function bbp_remove_user_from_all_objects( $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
     78    $retval = delete_metadata( $meta_type, null, $meta_key, $user_id, true );
     79
     80    // Filter & return
     81    return (bool) apply_filters( 'bbp_remove_user_from_all_objects', (bool) $retval, $user_id, $meta_key, $meta_type );
    5982}
    6083
Note: See TracChangeset for help on using the changeset viewer.