WordPress.org

Ready to get started?Download WordPress

Forums

Add New Default Avatar
Missing argument 5 for Add_New_Default_Avatar::get_avatar() (4 posts)

  1. paullee357
    Member
    Posted 1 year ago #

    I had your plugin working great until Installed our key subscription service we intend to use (aMember). Now I see an error on the back end and front end.

    Warning: Missing argument 5 for Add_New_Default_Avatar::get_avatar() in /...path.../wp-content/plugins/add-new-default-avatar/kl_addnewdefaultavatar.php on line 132

    http://wordpress.org/extend/plugins/add-new-default-avatar/

  2. paullee357
    Member
    Posted 1 year ago #

    Not sure why it is now fixed or the consequences of doing this but in the get_avatar function I set the field to $alt = false

  3. marties
    Member
    Posted 1 year ago #

    hi,

    i have the same problem, where exactly did paste $alt=false

    function get_avatar( $avatar, $id_or_email, $size, $default='', $alt ) {
    
    		if ( is_numeric( $id_or_email ) ) {
    			$email = get_userdata( $id_or_email )->user_email;
    			$user_id = (int) $id_or_email;
    		}
    		elseif ( is_object( $id_or_email ) ) {
    			$email = $id_or_email->comment_author_email;
    			$user_id = (int) $id_or_email->user_id;
    		}
    		elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) ) {
    			$email = $id_or_email;
    			$user_id = $user->ID;
    		}
    
    		// special exception for our 10up friends
    		// http://wordpress.org/extend/plugins/simple-local-avatars/
    		// (and check hook suffix while we're at it, if the current user has a simple_local_avatar, it'll throw the list off)
    		$local_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
    		if ( ! empty( $local_avatars ) && ( isset( $GLOBALS['hook_suffix'] ) && $GLOBALS['hook_suffix'] != 'options-discussion.php' ) ) {
    			remove_filter( 'get_avatar', array( &$this, 'get_avatar' ), 88, 5 );
    			return $avatar;
    		}
    
    		// since we're hooking directly into get_avatar,
    		// we need to make sure another avatar hasn't been selected
    		/* Once upon a time was needed for Mr WordPress. Do we care?
    		$direct = get_option('avatar_default');
    		if ( strpos( $default, $direct ) !== false ) {
    			$email = empty( $email ) ? 'nobody' : md5( $email );
    
    			// in rare cases were there is no email associated with the comment (like Mr WordPress)
    			// we have to work around a bit to insert the custom avatar
    			// 'www' version for WP2.9 and older
    			if ( strpos( $default, 'http://0.gravatar.com/avatar/') === 0 || strpos( $default, 'http://www.gravatar.com/avatar/') === 0 )
    				$avatar = str_replace( $default, $direct, $avatar );
    
    		}
    		*/
    		// hack the correct size parameter back in, if necessary
    		$avatar = str_replace( '%size%', $size, $avatar );
    		$avatar = str_replace( urlencode('%size%'), $size, $avatar );
    		return $avatar;
    	}
  4. marties
    Member
    Posted 1 year ago #

    hi,

    answering myself for google

    in the declaration's function

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

    simply change to

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

    Gone!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.