function gwpm_get_avatar($avatar, $id_or_email, $size, $default) { global $wpdb; appendLog($id_or_email); if (strpos($default, GWPM_AVATAR) !== false) { $imageURL = GWPM_PUBLIC_IMG_URL . URL_S . 'gwpm_icon.png'; appendLog("isAdmin: " . is_admin()); if (!is_admin()) { appendLog("Not Admin page"); if (is_object($id_or_email)) { if ($id_or_email->ID) { $id_or_email = $id_or_email->ID; } else { if ($id_or_email->user_id) { $id_or_email = $id_or_email->user_id; } else { if ($id_or_email->comment_author_email) { $id_or_email = $id_or_email->comment_author_email; } } } } if (is_numeric($id_or_email)) { $userid = (int) $id_or_email; } else { if (is_string($id_or_email)) { $userid = (int) $wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE user_email = '" . mysql_escape_string($id_or_email) . "'"); } } $imageURL = getGravatarImageForUser($userid); } appendLog("imageURL: " . $imageURL); $doc = new DOMDocument(); $doc->loadHTML($avatar); $imageTags = $doc->getElementsByTagName('img'); foreach ($imageTags as $tag) { appendLog($tag->getAttribute('src')); $imgSrc = $tag->getAttribute('src'); $tag->setAttribute("src", $imageURL); $avatar = $tag->ownerDocument->saveXML($tag); appendLog("altered avatar: "); } } return $avatar; }
<th class="column-name" valign="top">Email Id</th> <th class="column-name" valign="top">Action</th> </tr> </thead> <?php foreach ($resultObj as $userObj) { ?> <tbody> <tr> <td valign="top"><?php gwpm_echo($counter); ?> </td> <td valign="top"><?php $gravatarDetail = get_avatar($userObj->ID, 48); $gravatarDetail = $gravatarDetail ? $gravatarDetail : getGravatarImageForUser($userObj->ID, true); echo $gravatarDetail; ?> </td> <td valign="top"><a href="<?php echo get_site_url() . '?page_id=' . $page_id . '&page=profile&action=view&pid=' . $userObj->ID; ?> " target="_blank"><?php gwpm_echo(GWPM_USER_PREFIX . $userObj->ID); ?> </a></td> <td valign="top"><?php gwpm_echo($userObj->display_name); ?>