Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#10240 closed enhancement (fixed)

Contact Info needs to be filterable

Reported by: joostdevalk's profile joostdevalk Owned by: joostdevalk's profile joostdevalk
Milestone: 2.9 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch tested
Focuses: Cc:

Description

Right now the Contact Info is a "fixed" set of values: Email, Website, AIM, Yahoo IM, Jabber / Google Talk. With the advent of the the_author_meta functions, the way has been cleared for this entire thing to be filterable, so people can add and remove their own contact options from within a plugin.

This would require, if I'm correct, for the Contact Info to be a loop through an array of contact options, and that array has to be filtered, with the exception of the E-mail address, which should always be available.

Thoughts and remarks are very welcome :)

Attachments (1)

contactmethods.patch (4.1 KB) - added by joostdevalk 15 years ago.
Patch

Download all attachments as: .zip

Change History (21)

#1 @Denis-de-Bernardy
15 years ago

  • Component changed from General to Users
  • Keywords needs-patch added; dev-feedback 2nd-opinion removed

I like this idea.

#2 @joostdevalk
15 years ago

  • Keywords has-patch added; needs-patch removed

I've added a first patch, it's a bit rough on the edges, as I was especially unsure where to store the "default" variables, as they have to be available both in the admin and the frontend...

#3 @joostdevalk
15 years ago

  • Keywords needs-testing added

#4 @joostdevalk
15 years ago

Changed the way the patch works, now simply adding a private function to wp-admin/includes/user.php that is called in the few spots where the contactmethods are needed.

#5 follow-up: @joostdevalk
15 years ago

Sample implementation:

function add_twitter_contactmethod( $contactmethods ) {
	// Add Twitter
	$contactmethods['twitter'] = 'Twitter';
	
	// Remove Yahoo IM
	unset($contactmethods['yim'])
	
	return $contactmethods;
}
add_filter('user_contactmethods','add_twitter_contactmethod',10,1);

@joostdevalk
15 years ago

Patch

#6 in reply to: ↑ 5 @joostdevalk
15 years ago

Don't forget the closing semi colon after the unset of course:

Sample implementation:

function add_twitter_contactmethod( $contactmethods ) {
  // Add Twitter
  $contactmethods['twitter'] = 'Twitter';
	
  // Remove Yahoo IM
  unset($contactmethods['yim']);
 	
  return $contactmethods;
}
add_filter('user_contactmethods','add_twitter_contactmethod',10,1);

#7 follow-up: @markjaquith
15 years ago

I worked with Joost a bit on this patch. I'm +1 on it.

#8 in reply to: ↑ 7 @joostdevalk
15 years ago

Replying to markjaquith:

I worked with Joost a bit on this patch. I'm +1 on it.

For which I'm grateful, btw :)

#9 @demetris
15 years ago

I quickly tested the patch against trunk and 2.8-branch, and everything seems to work OK, both in removing and in adding contact methods.

#10 @Denis-de-Bernardy
15 years ago

  • Keywords tested added; needs-testing removed

#11 @Viper007Bond
15 years ago

Looks cool to me. :)

#12 @aaroncampbell
15 years ago

  • Cc aaroncampbell added

I tested it on trunk (Revision 11754) and was able to add, remove, and override options just fine. Works great.

#13 @westi
15 years ago

Excellent.

This is something I expected to be there when writing this:

http://blog.ftwr.co.uk/archives/2009/07/19/adding-extra-user-meta-fields/

Was disappointed to find it wasn't.

This patch makes that plugin into just a filter which is what I hoped I needed at the time.

#14 @westi
15 years ago

Cool.

Only found one little buglet to do with not setting default values on the WP_User object when loaded for the new contact types which I've fixed in the commit.

This meant you got a notice in the value field for your new contact info item.

#15 @westi
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11784]) Make it much easier to filter contact methods from user profiles adding and removing at will. Fixes #10240 props joostdevalk.

#16 follow-up: @ryan
15 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The registration.php changes seem to be sporadically stomping usermeta values.

#17 in reply to: ↑ 16 @westi
15 years ago

Replying to ryan:

The registration.php changes seem to be sporadically stomping usermeta values.

Hmm - any clue on what is triggering that?

#18 @ryan
15 years ago

Actually, the api_key field that is added to the users table (not usermeta) on wordpress.com was getting stomped. I haven't conclusively tied it to this changeset, but the problem started moments after I merged this changeset and seem to have stomped since reversion.

#19 @ryan
15 years ago

Maybe since api_key is not a standard users table field, it is getting tossed out somehow.

#20 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Anyhow, since this is looking .com specific, I'll close this again until I can pin it down.

Note: See TracTickets for help on using tickets.