WordPress.org

Ready to get started?Download WordPress

Forums

User Avatar
How Do I Use PHP to Call the Custom Avatar? (3 posts)

  1. Denis Lam
    Member
    Posted 1 year ago #

    I would like to call the avatar to be displayed on a page template, is there documentation on how I would call it?

    http://wordpress.org/extend/plugins/user-avatar/

  2. Denis Lam
    Member
    Posted 1 year ago #

    Specifically, I just want to call the avatar's URL...

    <?php echo user_avatar_get_avatar(get_the_author_meta('ID')); ?> shows the image html. I just want the image path.

  3. Denis Lam
    Member
    Posted 1 year ago #

    I don't know if there's an easier way but in my functions.php I added this new function that seems to do the trick.

    function user_avatar_url( $item_id ) {
    
    	if( $avatar_img = user_avatar_avatar_exists( $item_id ) ):
    
    		$avatar_src = get_site_url()."/wp-content/uploads/avatars/".$item_id."/".$avatar_img;
    		if(function_exists('is_subdomain_install') && !is_subdomain_install())
    			$avatar_src = "/wp-content/uploads/avatars/".$item_id."/".$avatar_img;
    
    		$avatar_folder_dir = USER_AVATAR_UPLOAD_PATH."{$item_id}/";
    
    		$file_time = filemtime ($avatar_folder_dir."/".$avatar_img);
    
    		$avatar_url = $avatar_src;
    
    		return  $avatar_url ;
    	else:
    		return false;
    	endif;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.