How to set a username via url

Hi,
is there a trick, to set the username by URL #parameter. It should work also if no user-Information is preconfigured in the wiki.
Background is the idea of combining TW and moodle, where this would be the way a plugin could use this to transfer the user information.

  • I would prefer a way that works without further clicking with a startup-action.
  • The other way I imagine this could be done a missing tiddler Template which only affects missing tiddlers prefixed with something like user, which could generate a button to log in.

@JanJo this has being discussed at some length in other threads, I presume you are referring to single file wikis?

  • The idea of missing tiddlers etc… was in my view more complex than needed

However

  • Using something like this file:///C:/Scratch/loadwithuser.html?username will place ?username in the shadows tiddler $:/info/url/search
  • Then we need to set $:/status/UserName

I tested this in a tiddler tagged $:/tags/StartupAction containing;

<$action-setfield $tiddler="$:/status/UserName" $field="text" $value={{{ [{$:/info/url/search}removeprefix[?]] }}}/>

However be warned;

  • If you rely on Timimi to save your wiki it unfortunately fails if you use have ? in the url.
  • It is easy for the user to see their link, then try and use it for another username
  • It may be worth using ?username=hash where hash in an unfriendly string you cant search for in the wiki.

Will the user linking to the wiki have save rights? and if so using what save mechanisium?

1 Like

Thanks! This was what I needed.

So this is the recipe:

Insert this to a tiddler:

Tag it $:/tags/StartupAction

And here you go: The Input after the question mark is the username.

Yes and you can add this to a permalink or permaview.

Hi,
I thought it might be smart to use https://wikiurl?u=username , this would make possible to use the ? Param for other searches.

Thus the startupaction would be:

<$action-setfield $tiddler="$:/status/UserName" $field="text" $value={{{ [{$:/info/url/search}removeprefix[?u=]] }}}/>

I made a handy dual use version for search and user url handovers
$ _URLSearch&UserStartup.json (697 Bytes)

  • url?xyz transfers xyz to $:/temp/search
  • url?u=xyz transfers xyz to $:/status/UserName
3 Likes