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.
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/
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...
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