Please or Register to create posts and topics.

How to set in a post an hyperlink using the current user id?

Hi,

Just a question in case any one has the solution.
It not specifically related to Asgaros.

To help users I write some how-to.
Sometimes, to make it easier, I include hyperlinks to pages/functionalities.
But sometimes I need the current user’s id to build the url.

For example. On Asgaros or Ultimate Member for another website, in my advises, I suggest users to update their profile (the Asgaros or Ultimate Member profile).
So I would like to add in my advises the hyperlink to the profile page to make it easier.

But either on Asgaros or Ultimate Member, the URL looks like that:
https://www.mywebsite.com/user/wp_user_id/
https://www.mywebsite.com/profile/wp_user_id/

They both need the current user’s user_id.
So how can I include the current user’s id in an hyperlink in a post?

Can we use any kind of BBcode, short code, html/php code, etc.?
Or does an extension provide this possibility?

Thanks!

Hello @ftp

I think what you require is some kind of custom-plugin which adds a new shortcode to your site. For this shortcode a URL must be defined so that the ID of the current user can be applied to it automatically at a defined position. Asgaros Forum also supports custom-shortcodes so it would be possible to use it inside of the forum as well.

However, such a functionality can only be added by a custom-plugin and requires knowledge in the WordPress-API and PHP. Here you can find more information:

https://torquemag.io/2017/06/custom-shortcode/

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Hi @asgaros,

You’ve put me on the right way!

User Shortcodes

User Shortcodes Plus

It works like a charm, including on Asgaros 😉

Thanks very much!

Asgaros has reacted to this post.
Asgaros