PHP Forums Archive

Show / hide profile information in bbpress

Tags: registration, profile, filter, fields

Olaf posted on 2009-09-29 06:01:28 #

On the bbpress forum I noticed often the question how to add/edit/remove profile options for each member. Many people like to remove the members website URL and other like to see more details about a member.

I use the following function / code for this forum (just put the code into your personal plugin file (my-plugins/my_plugins.php).

function set_my_profile_info_keys($myarray) {
	$myarray = array(
		'first_name' => array(0, __('First name')),
		'last_name' => array(0, __('Last name')),
		'display_name' => array(1, __('Display name as')),
		'user_email' => array(1, __('Email')),
		//'user_url' => array(0, __('Website')),
		'from' => array(0, __('Location')),
		'occ' => array(0, __('Occupation')),
		'interest' => array(0, __('Interests'))
	);
    return $myarray;
}
add_filter('get_profile_info_keys', 'set_my_profile_info_keys');

You see that "disabled" value for "user_url" and added the values for first name, last name and display name. The values "0" and "1" indicate if a value is required or not.

Comments / discussions

iank posted on 2009-10-11 07:26:59 #

I am new to this forum and new to php and you have great advises here, and I like this function that you have created, however, can you advise how do I make use of it in the profile.php?

Thank you :)

Olaf posted on 2009-10-11 07:30:10 #

Hi iank and welcome!

If you use this filter / function it works for the register function and the profile page.
All profile fields are controlled by this function.

Do you created your own plugin file with this function?