WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Larswp
    Member
    Posted 10 months 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
    grateful

    http://wordpress.org/extend/plugins/simple-local-avatars/

  2. draiz
    Member
    Posted 9 months 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
    Member
    Posted 9 months ago #

    ^^^ this fixes it thanks!

  4. altercode
    Member
    Posted 8 months ago #

    Thanks for the fix!

  5. cdrom
    Member
    Posted 7 months ago #

    With the fix, it's top !

    Thanks

  6. xnau
    Member
    Posted 6 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
    Member
    Posted 6 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.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.