[wp-trac] [WordPress Trac] #24952: Intoduce new API - "User Profile Contact Methods API"

WordPress Trac noreply at wordpress.org
Mon Aug 5 09:09:41 UTC 2013


#24952: Intoduce new API - "User Profile Contact Methods API"
-----------------------------+--------------------------------------
 Reporter:  ramiy            |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Users            |    Version:  trunk
 Severity:  normal           |   Keywords:  needs-patch dev-feedback
-----------------------------+--------------------------------------
 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

--
Ticket URL: <http://core.trac.wordpress.org/ticket/24952>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list