/** * Get the user associated with the specified OpenID. * * @param string $openid identifier to match * @return int|null ID of associated user, or null if no associated user * @access public * @since 3.0 */ function get_user_by_openid($url) { global $wpdb; return $wpdb->get_var(wpdb_prepare('SELECT user_id FROM ' . openid_identity_table() . ' WHERE url = %s', $url)); }
/** * Remove all identity urls from user. * * @param int $user_id user id */ function openid_drop_all_identities($user_id) { global $wpdb; return $wpdb->query(wpdb_prepare('DELETE FROM ' . openid_identity_table() . ' WHERE user_id = %s', $user_id)); }
/** * Migrate old data to new locations. */ function openid_migrate_old_data() { global $wpdb; // remove old nonce and associations tables $wpdb->query('DROP TABLE IF EXISTS ' . openid_table_prefix(true) . 'openid_nonces'); $wpdb->query('DROP TABLE IF EXISTS ' . openid_table_prefix(true) . 'openid_associations'); // update old style of marking openid comments. For performance reason, we // migrate them en masse rather than using set_comment_openid() $comments_table = openid_table_prefix(true) . 'comments'; $comment_data = $wpdb->get_results(wpdb_prepare('SELECT comment_ID, comment_post_ID from ' . $comments_table . ' WHERE openid=%s OR comment_type=%s', 1, 'openid')); if (!empty($comment_data)) { $openid_comments = array(); foreach ($comment_data as $comment) { if (!array_key_exists($comment->comment_post_ID, $openid_comments)) { $openid_comments[$comment->comment_post_ID] = array(); } $openid_comments[$comment->comment_post_ID][] = $comment->comment_ID; } foreach ($openid_comments as $post_id => $comments) { $current = get_post_meta($comment->comment_post_ID, 'openid_comments', true); if (!empty($current)) { $comments = array_merge($comments, $current); } update_post_meta($post_id, 'openid_comments', array_unique($comments)); } } @$wpdb->query('ALTER table ' . $comments_table . ' DROP COLUMN openid'); $wpdb->query(wpdb_prepare('UPDATE ' . $comments_table . ' SET comment_type=%s WHERE comment_type=%s', '', 'openid')); // remove old style of marking openid users $usermeta_table = defined('CUSTOM_USER_META_TABLE') ? CUSTOM_USER_META_TABLE : openid_table_prefix() . 'usermeta'; $wpdb->query(wpdb_prepare('DELETE FROM ' . $usermeta_table . ' WHERE meta_key=%s OR meta_key=%s', 'has_openid', 'registered_with_openid')); }