Deactivate MB plugin and user avatar snippet stopped functioning

Support Meta Box AIO Deactivate MB plugin and user avatar snippet stopped functioning

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #47676
    Care DigitalCare Digital
    Participant

    Hi everyone,

    As MB AIO now supports MB Framework, I tried to deactivate the Metabox plugin and a snippet stopped functioning. The snippet is supposed to update user avatar from 'avatar' single image custom field. It just stopped functioning and all the avatar reverts back to placeholder. All the setting and ID are not changed at all for CPT and custom fields.

    Upon reactivating Metabox plugin, the avatar photos came back like normal. Here is the snippet I'm using which I don't know if AIO now has different function that normal Metabox plugin or not:

    
    // Get user avatar from Metabox Image field
    add_filter( 'get_avatar_url', 'mb_get_avatar_url', 10, 3 );
    function mb_get_avatar_url( $url, $id_or_email, $args ) {
        if ( is_numeric( $id_or_email ) ) {
            $user_id = $id_or_email;
        } elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) ) {
            $user_id = $user->ID;
        } elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) {
            $user_id = (int) $id_or_email->user_id;
        }
        if ( empty( $user_id ) ) {
            return $url;
        }
        // change after rwmb_meta to 'the custom field id'
        $custom_avatar = rwmb_meta( 'avatar', [ 'object_type' => 'user' ], $user_id );
        if ( ! $custom_avatar ) {
            return $url;
        }
        $url = $custom_avatar['full_url'];
        return $url;
    }
    add_filter( 'init', function() {
        global $wp_rewrite;
        $wp_rewrite->author_base = 'user';
    });
    #47677
    DanielDaniel
    Participant

    Hello, similar issue happened to me - deactivated MB on 10 sites because I saw the notes of the new AIO plugin and discovered later that the group fields no longer work correctly ("Add..." button is no longer visible).

    #47679
    PeterPeter
    Moderator

    Hello Care Digital,

    I use that snippet on my site and deactivate Meta Box plugin but don't see the issue. Here is the screenshot https://imgur.com/Q7mfAm3

    Can you please share some screenshots of the issue on your site and let me know how to reproduce it?

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.