Opened 15 years ago
Closed 15 years ago
#10240 closed enhancement (fixed)
Contact Info needs to be filterable
Reported by: | joostdevalk | Owned by: | 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)
Change History (21)
#1
@
15 years ago
- Component changed from General to Users
- Keywords needs-patch added; dev-feedback 2nd-opinion removed
#2
@
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...
#4
@
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:
↓ 6
@
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);
#6
in reply to:
↑ 5
@
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);
#8
in reply to:
↑ 7
@
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
@
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.
#12
@
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
@
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
@
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.
#16
follow-up:
↓ 17
@
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
@
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
@
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.
I like this idea.