Support » Plugin: Avatar Privacy » Undefined offset – Avatars not shown

  • Resolved Sascha_Foerster

    (@sascha_foerster)


    Hi there, thanks for the great plugin, which really should be just core.

    I have an multisite (multinetwork) installation, with your plugin network-activated. It worked perfectly with our theme “Newspaper” in a single-dev-installation, but now: only grey men are visible, even though our authors have checked in for gravatar or uploaded pictures themselves.

    I cleaned up all the caches of your plugin, after that I could see this error message:

    PHP Notice: Undefined offset: 2 in .../wordpress/wp-content/plugins/avatar-privacy/includes/avatar-privacy/components/class-avatar-handling.php on line 165, referer: https://bundesstadt.com/wp-admin/

    But from there, I am lost and I and all the authors here would appreciate your help:

    https://bundesstadt.com/ueber-bundesstadt-com/autoren/

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author pepe

    (@pputzer)

    The notice is harmless and unrelated to the problem. Is the sourcecode for the theme publicly available somewhere? I’ve got a suspicion that it calls get_avatar with an email address instead of a user ID, so the plugin thinks these are anonymous comment authors instead of registered users.

    Plugin Author pepe

    (@pputzer)

    @sascha_foerster Maybe I read through your report a bit hastily yesterday. The plugin works fine with your theme in a singlesite install? While I’m using it personally in a multisite install, I have not tried it in a multi-network environment (although theoretically it should be fine).

    All these authors are registered WP users?

    Plugin Author pepe

    (@pputzer)

    The “undefined offset” warning is fixed in 1.0.7. I’d need more information for looking at the real issue, though.

    Sorry for my late reply. I appreciate your quick action! I needed some time to look deeper into the problem and learn to use “grep”. We are using the theme “Newspaper”: https://themeforest.net/item/newspaper/5489609

    I looked into the files newspapers offers and here is what I found:

    
    ./Newspaper/functions.php:			$author_avatar = get_avatar( bbp_get_topic_author_id( $topic_id ), $size );
    ./Newspaper/functions.php:			$author_avatar = get_avatar( get_post_meta( $topic_id, '_bbp_anonymous_email', true ), $size );
    ./Newspaper/includes/shortcodes/td_block_authors.php:                $buffy .= '<a href="' . get_author_posts_url($td_author->ID) . '">' . get_avatar($td_author->user_email, '70') . '</a>';
    ./Newspaper/includes/shortcodes/td_block_author.php:				    $buffy .= '<a href="#">' . get_avatar('', '196') . '</a>';
    ./Newspaper/includes/shortcodes/td_block_author.php:        $buffy .= '<a href="' . get_author_posts_url($td_author->ID) . '">' . get_avatar($td_author->user_email, '196') . '</a>';
    ./Newspaper/includes/wp_booster/td_module_single_base.php:            $buffy .= get_avatar(get_the_author_meta('email', $author_id), '96');
    ./Newspaper/includes/wp_booster/comments.php:	                    //echo get_avatar($td_comment_auth_email, 50, get_template_directory_uri() . "/images/avatar.jpg");
    ./Newspaper/includes/wp_booster/comments.php:	                    echo get_avatar($td_comment_auth_email, 50);
    ./Newspaper/mobile/comments.php:	                    //echo get_avatar($td_comment_auth_email, 50, get_template_directory_uri() . "/images/avatar.jpg");
    ./Newspaper/mobile/comments.php:	                    echo get_avatar($td_comment_auth_email, 50);
    ./Newspaper/mobile/parts/logged.php:		<div class="td-menu-avatar"><div class="td-avatar-container">' .	get_avatar($current_user->ID, 80) .	'</div></div>
    ./Newspaper/mobile/parts/login.php:        <div class="td-menu-avatar"><div class="td-avatar-container">' . get_avatar($current_user->ID, 80) . '</div></div>
    ./Newspaper/mobile/author.php:		        <?php  echo get_avatar($part_cur_auth_obj->user_email, '96'); ?>
    ./Newspaper/parts/logged.php:		<div class="td-menu-avatar"><div class="td-avatar-container">' .	get_avatar($current_user->ID, 80) .	'</div></div>
    ./Newspaper/parts/login.php:        <div class="td-menu-avatar"><div class="td-avatar-container">' . get_avatar($current_user->ID, 80) . '</div></div>
    ./Newspaper/parts/page-author-box.php:    <?php  echo get_avatar($part_cur_auth_obj->user_email, '96'); ?>
    ./Newspaper/parts/header/top-menu.php:                            get_avatar($current_user->ID, 20) . '<a href="' . get_author_posts_url($current_user->ID) . '" class="td_user_logd_in">' . $current_user->display_name . '</a>' .
    Plugin Author pepe

    (@pputzer)

    Difficult to tell from single lines. The theme does work correctly with Avatar Privacy on a single-site installation?

    Maybe I was wrong, so don’t get confused with it. I am not so sure, if maybe caching was helping somehow, I didn’t look into all the details there.

    I changed most places with “email” to “ID” and it works well. Had to create a child-theme for that.

    Only place, where it doesn’t work is comments: when I add ID, it looks like the author wrote all of the comments. ­čÖé

    Why is “email” not working here? Is there no way, because I try to avoid to get to many files in my child theme, just this needed changing of 7 files.

    Plugin Author pepe

    (@pputzer)

    The problem is, you can’t just switch all calls of get_avatar to use a user ID (which one?), because that’s not right either. You should only do that where you are indeed trying to display the avatar of a registered user.

    Oh, and we can switch to German if that’s easier ­čÖé

    Die Frage, ob das Thema + Avatar Privacy in der Single-Site-Installation funktioniert haben, war, weil ich nicht ausschlie├čen kann, da├č im Multi-Network-Betrieb noch irgendwelche Fallstricke lauern. In so einer Umgebung habe ich das Plugin einfach nicht getestet (in “simplen” Multi-Site-Installationen hingegen schon).

    Am einfachsten ist es vermutlich, wenn Du mir einmal eine Mail schreibst.

    Plugin Author pepe

    (@pputzer)

    @sascha_foerster Hat das mit per Mail ├╝bermittelten Code geklappt?

    Plugin Author pepe

    (@pputzer)

    I assume the issue has been resolved.

    Sorry for my late reply! I just had to reverse all my manual changes to the child theme, so see, if everything works out!

    I’m not sure, if you should make a difference for logging in users to show an avatar with just the id or the email, when not logged in, but now I am happy, because with two checks in my profile, the avatar is shown everywhere, where it should be visible.

    I hope this will be added to core, because it should! Thanks for your great support!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Undefined offset – Avatars not shown’ is closed to new replies.