Opened 4 years ago
Closed 4 years ago
#10240 closed enhancement (fixed)
Contact Info needs to be filterable
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9 |
| Component: | Users | Version: | |
| Severity: | normal | Keywords: | has-patch tested |
| Cc: | aaroncampbell |
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)
comment:1
Denis-de-Bernardy
— 4 years ago
- Component changed from General to Users
- Keywords needs-patch added; dev-feedback 2nd-opinion removed
comment:2
joostdevalk
— 4 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...
comment:3
joostdevalk
— 4 years ago
- Keywords needs-testing added
comment:4
joostdevalk
— 4 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.
comment:5
follow-up:
↓ 6
joostdevalk
— 4 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);
comment:6
in reply to:
↑ 5
joostdevalk
— 4 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);
comment:7
follow-up:
↓ 8
markjaquith
— 4 years ago
I worked with Joost a bit on this patch. I'm +1 on it.
comment:8
in reply to:
↑ 7
joostdevalk
— 4 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 :)
comment:9
demetris
— 4 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.
comment:10
Denis-de-Bernardy
— 4 years ago
- Keywords tested added; needs-testing removed
comment:11
Viper007Bond
— 4 years ago
Looks cool to me. :)
comment:12
aaroncampbell
— 4 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.
comment:13
westi
— 4 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.
comment:14
westi
— 4 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.
comment:15
westi
— 4 years ago
- Resolution set to fixed
- Status changed from new to closed
comment:16
follow-up:
↓ 17
ryan
— 4 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
The registration.php changes seem to be sporadically stomping usermeta values.
comment:17
in reply to:
↑ 16
westi
— 4 years ago
Replying to ryan:
The registration.php changes seem to be sporadically stomping usermeta values.
Hmm - any clue on what is triggering that?
comment:18
ryan
— 4 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.
comment:19
ryan
— 4 years ago
Maybe since api_key is not a standard users table field, it is getting tossed out somehow.
comment:20
ryan
— 4 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.
I like this idea.