Exemplo n.º 1
0
 /**
  * Get a username value stored for the given WordPress user identifier
  *
  * @since 1.3.0
  *
  * @param int|string $user_id WordPress user identifier. may be WP_User->ID or a separate identifier used by an extending system
  * @param string     $key user attribute or meta key storing the username of interest
  *
  * @return string stored username. empty string if no user_id provided or no username found
  */
 public static function getSocialUsername($user_id, $key)
 {
     // basic test for invalid passed parameter
     if (!$user_id) {
         return '';
     }
     if (!is_string($key) || !$key) {
         return '';
     }
     if (function_exists('get_user_attribute')) {
         $username = get_user_attribute($user_id, $key);
     } else {
         $username = get_user_meta($user_id, $key, true);
     }
     if (!is_string($username)) {
         $username = '';
     }
     // pass a username through a filter if not explicitly defined through user meta
     if (!$username) {
         /**
          * Allow sites to provide a WordPress user's Twitter username through a filter
          *
          * @since 1.0.0
          *
          * @param string     $username Twitter username associated with a WordPress user ID
          * @param int|string $user_id  WordPress user identifier. may be WP_User->ID or a separate identifier used by an extending system
          */
         $username = apply_filters($key . '_username', $username, $user_id);
     }
     return $username;
 }
/**
 * Patch for get_user_attribute to work with Field Manager.
 * @param  integer $user_id User ID.
 * @param  string  $key     Optional key.
 * @param  boolean $single  True to return single value.
 *
 * @see    get_user_meta()
 *
 * @return mixed
 */
function wpcom_fieldmanager_get_user_attribute($user_id, $key, $single)
{
    $user_data = get_user_attribute($user_id, $key);
    if (!$single) {
        $user_data = array($user_data);
    }
    return $user_data;
}
function _wpcom_vip_custom_metadata_get_user_data_as_attributes($object_type, $object_id, $field_slug)
{
    return get_user_attribute($object_id, $field_slug);
}
 /**
  * Handle getting user meta across potential hosting platforms.
  *
  * @param int $user_id
  * @param string $key
  * @static
  * @return mixed
  * @access private
  */
 private static function get_user_meta($user_id, $key)
 {
     if (defined('WPCOM_IS_VIP_ENV') && true === WPCOM_IS_VIP_ENV) {
         return get_user_attribute($user_id, $key);
     } else {
         return get_user_meta($user_id, $key, true);
     }
 }
Exemplo n.º 5
0
 function AtD_get_setting($user_id, $name, $single = true)
 {
     return get_user_attribute($user_id, $name);
 }
Exemplo n.º 6
0
 /**
  * Adds hooks to register plugin with tinyMCE
  */
 function tinymce_register()
 {
     if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         return;
     }
     if (get_user_attribute(get_current_user_id(), 'rich_editing') == 'true' && user_can_richedit()) {
         add_filter('mce_external_plugins', array(&$this, 'add_tinymce_plugin'));
         add_filter('mce_buttons', array(&$this, 'add_tinymce_button'));
     }
     add_action('wp_ajax_dialog_button', array(&$this, 'dialog_button'));
 }
 /**
  * Wrapper utility method for using WordPress.com get_user_attribute() when available. Falls back to get_user_meta()
  *
  * @param           $user_id
  * @param           $meta_key
  * @param bool|true $single
  *
  * @return mixed
  */
 public static function get_user_meta($user_id, $meta_key, $single = true)
 {
     if (function_exists('get_user_attribute')) {
         $meta_value = get_user_attribute($user_id, $meta_key);
     } else {
         $meta_value = get_user_meta($user_id, $meta_key, $single);
     }
     return $meta_value;
 }
Exemplo n.º 8
0
 /**
  * Get user meta in a way that is also safe for VIP
  *
  * @param int $user_id
  * @param string $meta_key
  * @param bool $single (optional)
  *
  * @return mixed
  */
 function get_user_meta($user_id, $meta_key, $single = true)
 {
     if (wp_stream_is_vip() && function_exists('get_user_attribute')) {
         return get_user_attribute($user_id, $meta_key);
     }
     return get_user_meta($user_id, $meta_key, $single);
 }
Exemplo n.º 9
0
/**
 * Get the author meta smartly based on whether we're in the loop or on a post author page
 */
function hsinsider_get_the_author_meta($meta_key = false)
{
    global $coauthor;
    if (empty($meta_key)) {
        return false;
    }
    if (is_author()) {
        $author = get_queried_object();
        if (empty($author)) {
            return false;
        }
        $author_id = $author->ID;
    } elseif (!empty($coauthor) && is_object($coauthor)) {
        $author_id = $coauthor->ID;
    } else {
        $author_id = get_the_author_meta('ID');
    }
    if ('posts_url' == $meta_key) {
        return get_author_posts_url($author_id);
    }
    if ('school' == $meta_key) {
        return (int) get_user_attribute($author_id, '_lat_school', true);
    }
    return get_the_author_meta($meta_key, $author_id);
}
function fbwpcom_get_user_meta($original, $user_id, $key, $single)
{
    return get_user_attribute($user_id, $key, $single);
}
Exemplo n.º 11
0
 public function hsinsider_show_user_column_schools($value, $column_slug, $user_id)
 {
     if ($column_slug != 'school') {
         return $value;
     }
     $user = get_user_by('id', $user_id);
     if (!in_array('student', $user->roles)) {
         return $value;
     }
     $school = (int) get_user_attribute($user->ID, '_hsinsider_school', true);
     return wp_dropdown_categories(array('taxonomy' => 'school', 'hide_empty' => false, 'show_option_none' => 'None selected', 'selected' => $school, 'name' => wp_create_nonce('user_school-' . $user->ID), 'id' => 'user_school-' . $user->ID, 'class' => 'school', 'orderby' => 'name', 'echo' => false));
 }