# Change author url in WP to Discourse profile

**URL:** <https://meta.discourse.org/t/change-author-url-in-wp-to-discourse-profile/114687>\
**Category:** WordPress\
**Created:** [April 10, 2019, 6:39pm UTC](https://meta.discourse.org/t/change-author-url-in-wp-to-discourse-profile/114687 "2019-04-10T18:39:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [April 10, 2019, 8:49pm UTC](https://meta.discourse.org/t/change-author-url-in-wp-to-discourse-profile/114687/2 "2019-04-10T20:49:11Z")

</div>

> [@davidkingham](#):
>
> But I don’t know how to retrieve the discourse username from wordpress,

For users who have set their Discourse username on WordPress, you can get the username with:

```php
get_user_meta( $user_id, 'discourse_username', true );

```

`$user_id` needs to be set to the user’s WordPress user ID. Since it’s possible that not all authors will have set their Discourse username, you should probably check that the value returned isn’t `empty` before creating the link.

---

_[View the full topic](https://meta.discourse.org/t/change-author-url-in-wp-to-discourse-profile/114687)._
