[wp-trac] [WordPress Trac] #33542: User preferences API idea

WordPress Trac noreply at wordpress.org
Tue Aug 25 15:49:01 UTC 2015


#33542: User preferences API idea
-----------------------------+------------------------------
 Reporter:  johnjamesjacoby  |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Users            |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  2nd-opinion      |     Focuses:
-----------------------------+------------------------------

Comment (by johnjamesjacoby):

 Primitive, fuzzy pseudo-code might start by looking like this:

 {{{
 /**
  * Get a user preference
  *
  * @param  int     $user_id
  * @param  string  $key
  */
 function wp_get_user_preference( $user_id = 0, $key = '' ) {

         // Check usermeta first
         $retval = get_usermeta( $user_id, $key );

         // Nothing, so check site option
         if ( false === $retval ) {
                 $retval = get_option( $key );

                 // Nothing, so check network option if multisite
                 if ( false === $retval && is_multisite() ) {
                         $retval = get_site_option( $key );
                 }
         }

         // Filter & return
         return apply_filters( 'wp_get_user_preference', $retval, $user_id,
 $key );
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33542#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list