This solution involves adding code to the member module. You should always make a backup of any files that you change.
While editing some of the member profile templates i realised that there are a lot of tags that are not available. even very basic tags such as username are sometimes simply not parsed in the member profile templates (here is a list of available tags).
The available tags were insufficient for me as i wanted to display user information in places that it was unavailable, for example, to display custom member fields on the member profile home page. the following solution solves this by allowing you to place tags that retrieve member details in the content section of the member profile templates (see Full Profile Page in this member template guide).
To use this solution, place the following code into /system/modules/member/mod.member.php (make a backup first) in the manager function.
if ($this->cur_id == 'edit_folders') {$left = $this->profile_menu();}
if ($this->cur_id == 'send_message') {$left = $this->profile_menu();}
/** ------------------------------
/** Parse the template the template
/** ------------------------------*/
/*--- START NEW CODE ---*/
global $DB;
// query to get custom fields
$sql = "SELECT * FROM exp_member_fields";
$query = $DB->query($sql);
$custom_fields = array();
foreach($query->result as $row)
{
$custom_fields[$row['m_field_name']] = $row['m_field_id'];
}
// query to get user details and custom fields
$sql = "SELECT * FROM exp_members JOIN exp_member_data ON exp_members.member_id = exp_member_data.member_id WHERE exp_members.member_id = ".$SESS->userdata('member_id')."";
$query = $DB->query($sql);
if ($query->num_rows > 0)
{
$vars = $FNS->assign_variables($content, '/');
$this->var_single = $vars['var_single'];
foreach ($this->var_single as $key => $val)
{
// blank out the password for security purposes
if ($val == "password") {
$content = $this->_var_swap_single($val, "--", $content);
}
else if (isset($query->row[$val])) {
$content = $this->_var_swap_single($val, $query->row[$val], $content);
}
else if (isset($custom_fields[$val])) {
$content = $this->_var_swap_single($val, $query->row['m_field_id_'.$custom_fields[$val]], $content);
}
}
}
/*--- END NEW CODE ---*/
if ($left == '')
{
$out = $this->_var_swap($this->_load_element('basic_profile'),
array(
'include:content' => $content
)
);
}
else
{
$out = $this->_var_swap($this->_load_element('full_profile'),
array(
'include:menu' => $left,
'include:content' => $content
)
);
}
To use it, simply place a tag in the member profile template. the following tags are available (note that the password tag has been removed for security purposes):
{member_id}, {group_id}, {weblog_id}, {tmpl_group_id}, {upload_id}, {username}, {screen_name}, {unique_id}, {authcode}, {email}, {url}, {location}, {occupation}, {interests}, {bday_d}, {bday_m}, {bday_y}, {aol_im}, {yahoo_im}, {msn_im}, {icq}, {bio}, {signature}, {avatar_filename}, {avatar_width}, {avatar_height}, {photo_filename}, {photo_width}, {photo_height}, {sig_img_filename}, {sig_img_width}, {sig_img_height}, {ignore_list}, {private_messages}, {accept_messages}, {last_view_bulletins}, {last_bulletin_date}, {ip_address}, {join_date}, {last_visit}, {last_activity}, {total_entries}, {total_comments}, {total_forum_topics}, {total_forum_posts}, {last_entry_date}, {last_comment_date}, {last_forum_post_date}, {last_email_date}, {in_authorlist}, {accept_admin_email}, {accept_user_email}, {notify_by_default}, {notify_of_pm}, {display_avatars}, {display_signatures}, {smart_notifications}, {language}, {timezone}, {daylight_savings}, {localization_is_site_default}, {time_format}, {cp_theme}, {profile_theme}, {forum_theme}, {tracker}, {template_size}, {notepad}, {notepad_size}, {quick_links}, {quick_tabs}, {pmember_id}
Custom fields can also be shown. for example, if we have a custom field that is named city, then the tag {city} will return its value.
Please note that as stated above, these tags will only work in the content section of the member profile templates.
Category:Members Category:Hacks
