Skip Navigation

[Resolved] Get author of page by url

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 3 voices.

Last updated by Waqar 1 month, 3 weeks ago.

Assisted by: Waqar.

Author
Posts
#2695088
Screen Shot 2024-04-29 at 11.13.46 PM.png
Screen Shot 2024-04-29 at 11.13.20 PM.png

How can I embed a view via shortcode into wp widget that show on the buddyboss group pages and get the author of the page, by url or by someother way?

#2695117

Nigel
Supporter

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

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

Hi there

Can you clarify "get the author of the page"?

What page?

The URL in your screenshot for managing members doesn't look like it is a "page", and wouldn't have a post author.

#2695163

Oops, I mean this page: hidden link.

Where 'Brandon' is the usersname. I presume we can derive the wordpress user, from the url. Your instruction knowledge base, https://toolset.com/documentation/legacy-features/views-plugin/filtering-views-query-by-author/Using author usernames

/page/?xxxx=John Foo or /page/?xxxx[]=John Foo will show posts by the author whose username is John Foo. If no such author exists, no posts will be shown.
/page/?xxxx[]=John Foo&xxxx[]=Peter Bar will show posts by both the authors whose usernames are John Foo and Peter Bar. If one exists, his posts will be listed; if none exist, no posts will be displayed.
Note that if the URL parameter is missing or empty, all posts will be listed and no author filtering is done.

Makes it seem that we can only find the username as a constant, but not as a variable.

How can we derive the username from this url 'hidden link'?

when querying a view: https://toolset.com/wp-content/uploads/2024/04/2695088-Screen_Shot_2024_04_29_at_11.13.20_PM.png

#2695164

Like this: hidden link, but that view is not getting the author from the url.

#2695200
author-filter.png

Hi,

Thank you for sharing these details.

I would create a custom shortcode ( ref: https://codex.wordpress.org/Shortcode_API ), that can get the current URL, extract the last part (i.e. /brandon/ ) to get the username, and then return that username.

You can then set the view's post-author filter to get the target author from the view's shortcode attribute 'author', as shown in the attached screenshot.

And the output of that custom shortcode can be passed in the view's shortcode, for example:


[wpv-view name="view-name" author="[customshortcode]"]

regards,
Waqar

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.