Skip Navigation

[Resolved] View filter by current user nicename

This support ticket is created 2 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by JamesS2731 2 years, 10 months ago.

Author
Posts
#2292839

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:

Email Notifications

but looking at bbpress, it needs to be their nicename.

I tried:

Email Notifications

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

#2293097

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

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]"]
#2293383

Many thanks Nigel, that worked perfectly! Thank you for such a quick response.

Best regards
James