Title: Filter by User Name
Last modified: August 20, 2016

---

# Filter by User Name

 *  [Marlimant](https://wordpress.org/support/users/marlimant/)
 * (@marlimant)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/filter-by-user-name/)
 * Hello:
 * I have a link that varies by user.
    For now, it is work filtering by user id,
   but I need the code filter by **username**.
 * My actual code is:
 *     ```
       <?php $user_id = get_current_user_id();
       if ($user_id == 6) {
       echo '<a title="Download" href="http://www.mypage.cl/any_url-A/" rel="nofollow">';
       } else {
       echo '<a title="Download" href="http://www.mypage.cl/any_url-B/" rel="nofollow">';}?>
       <img src="http://www.mypage.cl/my_image-gif/" width="250" height="48" />
       </a>
       <?php global $post; $myposts = get_posts('numberposts=1&category_name=download'); foreach($myposts as $post) : setup_postdata($post);
        the_content();
        if(has_post_thumbnail()) {the_post_thumbnail();}
        endforeach; ?>
       ```
   
 * Thank you!

The topic ‘Filter by User Name’ is closed to new replies.

## Tags

 * [exclude](https://wordpress.org/support/topic-tag/exclude/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [user](https://wordpress.org/support/topic-tag/user/)

 * 0 replies
 * 1 participant
 * Last reply from: [Marlimant](https://wordpress.org/support/users/marlimant/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/filter-by-user-name/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
