Hi there,
I'm trying to create a dynamic link for the bbpress forum users to take them directly to their notification options.
I thought I could user their username in the link:
lien caché
but looking at bbpress, it needs to be their nicename.
I tried:
lien caché
but this then requires a query filter to limit the result to the current user.
Do you have any idea how I can either:
1. Use the user_nicename field but limit it to the current user
or
2. Use the nicename field with the wpb-current-user?
Any thoughts or ideas most welcomed.
Best regards
James
Hi James
It doesn't look either shortcode—on its own or in combination—is able to output the user nicename for the current user.
You can output the nicename with the wpv-user shortcode, but cannot specify the current user.
You can specify a specific user via the id attribute, so I suggest you register a simple custom shortcode that returns the ID of the current user, and use that to provide the value for the id attribute of the wpv-user shortcode.
So the shortcode would be like this:
add_shortcode('current-userid', function () {
$uid = get_current_user_id();
return $uid;
});
Then register this shortcode so that it can be used in Views shortcode arguments, at Toolset > Settings > Front-end Content > Third-party shortcode arguments.
You can then use the shortcode like so:
[wpv-user field="nicename" id="[current-userid]"]
Many thanks Nigel, that worked perfectly! Thank you for such a quick response.
Best regards
James