如何自动设置输入框中的用户名值?

您好!

我找到了这个脚本,用于在文本横幅中显示用户名:Display username when login in banner - #10 by tshenry

<script type="text/discourse-plugin" version="0.8.18">
    api.onPageChange(() => {
        if(api.getCurrentUser() != null) {
            $("#logged-in-user").text(" " + api.getCurrentUser().name.split(' ')[0]);
        }
    });
</script>
Hello, <span id="logged-in-user"></span>!

我需要创建一个自定义表单,并在输入框中自动设置用户名的值。我尝试在 value 中添加 <span id="logged-in-user"></span>,但它不起作用,我的代码是:

<input type="text" id="username" placeholder="@username" value="logged-in-user"/>
<input type="text" id="city" placeholder="City" value=""/>

<button id="Send">Send PM</button>

点击 Send 按钮后,我需要在操作按钮的链接中添加用户名和城市的值。
请帮忙 :pleading_face: