Opened 12 years ago
Closed 10 years ago
#24952 closed feature request (wontfix)
Intoduce new API - "User Profile Contact Methods API"
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.6 |
Component: | Users | Keywords: | close |
Focuses: | Cc: |
Description
WordPress has a very nifty filter called user_contactmethods that allows us to add user contact methods to the profile screen in the dashboard. We can add and remove contact methods using this code:
function custom_user_contact_methods( $user_contactmethods ){ // Remove contact methods unset($user_contactmethods['yim']); unset($user_contactmethods['aim']); unset($user_contactmethods['jabber']); // Add new contact methods $user_contactmethods['facebook'] = 'Facebook Username'; $user_contactmethods['twitter'] = 'Twitter Username'; return $user_contactmethods; } add_filter( 'user_contactmethods', 'custom_user_contact_methods' );
But i want to make it even easier and provide developers more tools to controll the user profile page. I think we need to create the new "User-Profile Contact-Methods API".
The general idea is to provide a set of functions:
- register_user_contact_method();
- usregister_user_contact_method();
- user_contact_method_exists();
- has_user_contact_method()
- ...
- ...
- ...
Something like that:
// Unregister contact methods $old_methods = array( 'yim', 'aim', 'jabber' ); unregister_user_contact_method( $old_methods ),
// Register contact methods $new_methods = array( 'facebook' => __( 'Facebook User Name', 'GenerateWP' ), 'twitter' => __( 'Twitter User Name', 'GenerateWP' ), ); register_user_contact_method( $new_methods );
// Check if contact method exist if ( user_contact_method_exists( 'skype' ) ) { // Do somthing }
// Check if the user has contact method (not empty) if ( has_user_contact_method( 'skype' ) ) { // Do somthing }
This way plugin authors will have better API to develop more complex tools within the dashboard.
This is the basic concept. Would like to hear your thoughts about this idea.
Rami Y.
GenerateWP.com
Change History (8)
#4
@
12 years ago
This is cool but I am not sure that we should to turn a dead-simple filter into a fully fledged API that adds no new functionality. Contact methods are nothing more than usermeta. I think all that is missing is just a public function for fetching registered contact methods.
#6
follow-up:
↓ 7
@
11 years ago
I'd vote against turning the contactmethods filter into an API, but fully support creating an API for adding fields to the user profile pages.
I think the idea that user profile pages only contain "contact methods" is silly, so if an API is to be created for adding any fields to the profile, it should be a generic API that can be used for adding contact methods, biography details, personal preferences, etc.
#7
in reply to:
↑ 6
@
11 years ago
- Keywords close added; needs-patch dev-feedback removed
Replying to nacin:
I think all that is missing is just a public function for fetching registered contact methods.
#24273 introduced wp_get_user_contact_methods()
.
Replying to mordauk:
I'd vote against turning the contactmethods filter into an API, but fully support creating an API for adding fields to the user profile pages.
Related: #12833
Related: #24273