Skip to:
Content

BuddyPress.org

Changeset 10484


Ignore:
Timestamp:
01/30/2016 09:41:55 PM (4 years ago)
Author:
djpaul
Message:

Emails: make sure we are on root blog when fetching email posts.

Potential compatibility fix for various multisite configurations,
especially with third-party plugins.

Props r-a-y

See #6592

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-functions.php

    r10481 r10484  
    27632763 */
    27642764function bp_get_email( $email_type ) {
     2765    $switched = false;
     2766
     2767    // Switch to the root blog, where the email posts live.
     2768    if ( ! bp_is_root_blog() ) {
     2769        switch_to_blog( bp_get_root_blog_id() );
     2770        $switched = true;
     2771    }
     2772
    27652773    $args = array(
    27662774        'no_found_rows'    => true,
     
    27902798    $post = get_posts( $args );
    27912799    if ( ! $post ) {
     2800        if ( $switched ) {
     2801            restore_current_blog();
     2802        }
     2803
    27922804        return new WP_Error( 'missing_email', __FUNCTION__, array( $email_type, $args ) );
    27932805    }
     
    28252837     * @param WP_Post[] All posts retrieved by get_posts( $args ). May only contain $post.
    28262838     */
    2827     return apply_filters( 'bp_get_email', $email, $email_type, $args, $post );
     2839    $retval = apply_filters( 'bp_get_email', $email, $email_type, $args, $post );
     2840
     2841    if ( $switched ) {
     2842        restore_current_blog();
     2843    }
     2844
     2845    return $retval;
    28282846}
    28292847
Note: See TracChangeset for help on using the changeset viewer.