Avatars in Register FormWhat this do is to allow the new users selet the avatar they want when they register.
What u have to do is this:
Open
register.php:
Find
the last:
$site_template->register_vars(array(
Replace:
//-----------------------
//------ Avatar ---------
//-----------------------
if ($config['avatar_use']){
$images = "";
$checked = ($user_avatar == "blank.gif" || $user_avatar == "") ? " selected" : "";
$images .= "\n<option value=\"blank.gif\"$checked>none</option>\n";
$dir = opendir(TEMPLATE_PATH."/avatars/users/");
while ($contents[] = readdir($dir)){;}
closedir($dir);
natcasesort ($contents);
foreach ($contents as $line){
$filename = substr($line,0,(strlen($line)-strlen(strrchr($line,"."))));
if ($filename == $user_info['user_id']) {
$checked = (stristr($user_avatar, "users/")) ? " selected" : "";
$images .= "\n<option value=\"users/$line\"$checked>".$lang['custom']."</option>\n";
}
}
$dir = opendir(TEMPLATE_PATH."/avatars/");
$contents = array();
while ($contents[] = readdir($dir)){;}
closedir($dir);
natcasesort ($contents);
$checked = "";
foreach ($contents as $line){
$filename = substr($line,0,(strlen($line)-strlen(strrchr($line,"."))));
$extension = substr(strrchr($line,"."), 1);
$checked = "";
if ($line == $user_avatar) { $checked = " selected"; }
if (strcasecmp($extension,"gif")==0 || strcasecmp($extension,"jpg")==0 || strcasecmp($extension,"jpeg")==0 || strcasecmp($extension,"png")==0 ){
if ($line != "blank.gif") {
$filename = str_replace("_", " ", $filename);
$images .= "<option value=\"$line\"$checked>$filename</option>\n";
}
}
}
}
//----------------------
//----- End Avatar -----
//----------------------
$site_template->register_vars(array(
"lang_avatar" => $lang['avatar'],
"lang_avatar_file" => $lang['avatar_file'],
"lang_avatar_dim" => $lang['avatar_max_dim']." ".$config['avatar_width']."x".$config['avatar_height'].$lang['px'],
"lang_avatar_select" => $lang['avatar_select'],
"user_avatar_images" => $images,
"user_avatar_current" => ($config['avatar_use']) ? "<img src=\"".TEMPLATE_PATH."/avatars/".(($user_avatar == "") ? "blank.gif" : $user_avatar)."\" name=\"icons\" border=\"0\" alt=\"\">" : "",
"lang_or" => $lang['or'],
"user_avatar_file" => $config['avatar_user_custom'],
Save changes.
Open templates/<your_templates>/
register_form.html:
Include:
<td colspan="3">{if user_avatar_images}
<tr>
<td class="row2" valign="top" colspan="3">{if user_avatar_file} <b>{lang_avatar_file}
</b><span class="smalltext"><b>(</b>{lang_avatar_dim}<b>)</b></span>
</td>
<td class="row2">{if user_avatar_file} {lang_upload} <input type="file" name="avatar_file" size="30" class="input" />
</td>
</tr>
<tr>
<td class="row1" colspan="3" >
<b><font color="#5CE960">O bien</font></b> , {endif
user_avatar_file} <b>{lang_avatar_select}
</b>{endif user_avatar_file} <select name="user_avatar" onkeypress="if(window.event.keyCode==13){ this.form.submit(); }" onChange="document.images.icons.src='{template_url}/avatars/'+document.creator.user_avatar.options[document.creator.user_avatar.selectedIndex].value;">
{user_avatar_images}
</select></td>
<td class="row1">{user_avatar_current}
</td>
</tr>
<tr>
<td colspan="3">{endif user_avatar_images}
</td>
If you see some errors tell me. But it does work
I hope this helpin the future