Skip Navigation

[Closed] link to a custom post type to buddypress user profile

This support ticket is created 4 years, 8 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.

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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 4 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1756621

I'm using Toolset to create a custom post type (Businesses) and BuddyPress to show the users profile page. I've been reading through all the previous forum posts I could find, but can't seem to get anything to work (posts I found were a bit old).

I would like to show the custom post type on a users profile - to OTHER users.

So, if I was to view users a profile, I can see they posted business a. And if I look at user b's profile... I can see they posted business B. And so on and so forth.

I know how to create a filter view based on the logged in user (so they only see their OWN posts), but having trouble getting it to dynamically show when they are on other users profile pages.

#1757467

Hello,

It needs custom codes, for example:
1) Create a custom shortcode to get current user's ID of BuddyPress profile page, add below codes in your theme file "functions.php":

add_shortcode('member-id', function($atts, $content) {
    if ( bp_is_user() ) {
        $user_id = bp_displayed_user_id();  
    } else {
        $user_id = bp_get_member_user_id();
    }
         
    return $user_id;
});

2) Dashboard-> Toolset-> Settings-> Front-end Content,
section "Third-party shortcode arguments", add the shortcode name: member-id

3) Create a post view, query posts of your custom post types
- Filter by "Post author filter":
Select posts which author's id is set by the View shortcode attribute "author" eg. [wpv-view name="view-name" author="1"]

4) In the BuddyPress profile page, display above post view's shortcode, like this:
[wpv-view name="view-name" author="[member-id]"]

More help:
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/

#1761025
Screen Shot 2020-08-29 at 8.23.00 pm.png
Screen Shot 2020-08-29 at 8.23.35 pm.png
Screen Shot 2020-08-29 at 8.23.41 pm.png

Hi. Thanks for the above. I've implemented it, however on the view it appears to be showing the end of the shortcode (see image). And it's showing the same business for each profile (last listed business).

Attached schreenshots of settings...

#1762023

Since it is a custom codes problem, please provide a test site with the same problem, fill below private message box with login details, also point out:
1) The problem page URL
2) Where I can edit your PHP codes,
I need to test and debug it in a live website, thanks

The topic ‘[Closed] link to a custom post type to buddypress user profile’ is closed to new replies.