# تغيير رابط المؤلف في WP إلى ملف تعريف Discourse

**URL:** <https://meta.discourse.org/t/change-author-url-in-wp-to-discourse-profile/114687>\
**Category:** WordPress\
**Created:** [10 أبريل 2019، 6:39م 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:** 4

<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:** [11 أبريل 2019، 12:50ص UTC](https://meta.discourse.org/t/change-author-url-in-wp-to-discourse-profile/114687/4 "2019-04-11T00:50:19Z")

</div>

> [@davidkingham](#):
>
> any idea why this would not be working?

Yes, `$user_id` isn’t available inside of your function. You need to pass the author’s id to the function as a parameter. Try this code. It also checks if the Discourse username has been set. If it’s not set, the default author link will be returned.

```php
add_filter( 'author_link', 'wpdc_modify_author_link', 10, 2 );
function wpdc_modify_author_link( $link, $author_id ) {
    $discourse_username = get_user_meta( $author_id, 'discourse_username', true );
    if ( ! empty( $discourse_username ) ) {
        return "https://community.naturephotographers.network/u/$discourse_username";
    }

	return $link;
}

```

---

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