Well, what you were getting is somehow expected. The content template does not know what post it should display.
There are two ways to pass the post to the content template:
- Put the content template inside the loop of a view that will return the user's UserProfile.
- Pass the ID of the user profile to the content template in the item attribute. https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
Because the content template includes the view that you hooked using Christian's code, we can't put it inside of the view's loop. So, I choose to use the second option(passing the ID to the content template using the item attribute).
For that, I created a new shortcode displayed-bp-user-id. This shortcode will return the UserProfile's ID of the visited bp user profile. This is the code.
add_shortcode('displayed-bp-user-id', 'my_displayed_bp_user_id');
function my_displayed_bp_user_id(){
$author_id = function_exists('bp_displayed_user_id') ? bp_displayed_user_id() : 0;
if ( $author_id == 0 ) return 0;
$posts = get_posts( array(
'post_type' => 'user-profile',
'author' => $author_id,
) );
if ( count( $posts ) == 0 ) return 0;
return $posts[0]->ID;
}
I added this code on the same snippet that you are using with the view.
I then, registered the shortcode in Toolset->Settings->Front-end Content(tab)->Third-party shortcode arguments. So, it can be used inside of other Toolset shortcodes(wpv-post-body)
Then, I used it in the content template shortcode:
[wpv-post-body view_template="template-for-user-profiles" item="[displayed-bp-user-id]"]
I hope this explains that a content template needs to know what post to display. And that everything I explained before makes sense to you.
I just want to add, that because we have passed the post's ID to the content template, there is no need to use a view inside of it. You can just display the information outside of the view, and drop the view and its custom code.
Let me know if you have any further questions.