Sure, you can do that by adding
api.changeWidgetSetting('home-logo', 'href', link);
just before the close tag for the script like so:
<script type="text/discourse-plugin" version="0.8.18">
const loggedIn = Discourse.User.current();
if (loggedIn != null) {
var username = loggedIn.username,
link = "//site.com/members/users/" + username;
} else {
var link = "//site.com";
}
api.changeWidgetSetting('home-logo', 'href', link);
</script>
Do note however that this is probably not a good idea.
You’re better off adding the link to the header as opposed to changing the logo. On every website I visit, my expectation is that clicking the logo will either take you to the homepage or to the top of the current page. I would find the change you’re trying to accomplish a bit annoying.
Try something like this instead:
<script type="text/discourse-plugin" version="0.8.18">
const loggedIn = Discourse.User.current();
if (loggedIn != null) {
var username = loggedIn.username,
link = "//site.com/members/users/" + username;
} else {
var link = "//site.com";
}
api.decorateWidget('header-icons:before', helper => {
return helper.h('li.wordpress-profile', [
helper.h('a.icon.btn-flat', {
href: link,
title: 'Your wordpress profile', // change link title
target: '_blank' // opens in a new tab
}, helper.h('i.fa.fa-user.d-icon')), // change link icon
]);
});
</script>
to add an icon with the dynamic link in the header like so:
You can then hide that icon for non-logged in users if you want with:
.anon .wordpress-profile {
display: none;
}
or you can keep it, depending on what icon you choose.