Ready to get started?Download WordPress


Simple Local Avatars
I found a problem on Simple Local Avatars 2.0 (7 posts)

  1. Larswp
    Posted 1 year ago #

    Hi friend! I found a problem on the plugin Simple Local Avatars 2.0 version.

    When a new user sign up in my website, this warning message appears on "Edit profile" page:
    Warning: Missing argument 2 for Simple_Local_Avatars::get_avatar() in /home/storage/a/26/ce/mywebsite/public_html/enespanol/wp-content/plugins/simple-local-avatars/simple-local-avatars.php on line 64

    In this case the user has not yet uploaded a picture, and can not add any photo.

    Your new plugin is very good, please help me


  2. draiz
    Posted 1 year ago #

    2.0 has an issue on line 64 where the argument for $id_or_email is missing.

    public function get_avatar( $avatar = '', $id_or_email, $size = 96, $default = '', $alt = '' )

    should be : public function get_avatar( $avatar = '', $id_or_email = '', $size = 96, $default = '', $alt = '' )

  3. cookney
    Posted 1 year ago #

    ^^^ this fixes it thanks!

  4. altercode
    Posted 1 year ago #

    Thanks for the fix!

  5. cdrom
    Posted 12 months ago #

    With the fix, it's top !


  6. xnau
    Posted 11 months ago #

    I also discovered this bug, but went a little further to find the reason it was happening in the first place.

    The static function get_simple_local_avatar() calls the class function Simple_Local_Avatars::get_avatar(). Because the plugin also puts a filter calling this function on the WP action 'get_avatar' the filter has to be suspended first. However, it was done incorrectly...instead of "remove_filter" "remove_action" was used, so the filter remains in place and the wrong function gets called. Here's how I fixed it:

    Old Code in file "simple-local-avatars.php" on line 536:

    if ( empty ( $avatar ) ) {
        remove_action( 'get_avatar', array( $simple_local_avatars, 'get_avatar' ));
        $avatar = get_avatar( $id_or_email, $size, $default, $alt );
        add_action( 'get_avatar', array( $simple_local_avatars, 'get_avatar' ) );

    New Code:

    if ( empty ( $avatar ) ) {
        remove_filter( 'get_avatar', array( $simple_local_avatars, 'get_avatar' ), 10 );
        $avatar = get_avatar( $id_or_email, $size, $default, $alt );
        add_filter( 'get_avatar', array( $simple_local_avatars, 'get_avatar' ), 10, 5 );
  7. m4olivei
    Posted 10 months ago #

    @xnau that didn't fix the issue for me. setting a default argument for $id_or_email in the get_avatar() function as mentioned by @draiz however, did.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.