Same problem. You can help? I also need this filter.
When I click on a member, the Site must show the events recorded by that user.
hidden link
This is the URL used by Buddypress. I need to create a filter where the authors of the event are the same as this member. How do I get that member?
Hi, I assume you are using a View to display Events on this page, is that correct? I can show you how to filter a View by post author, but I'm not sure how to access author information based on a Buddypress URL. I'm not trained in their software, so I'm not sure how to access that information. Their support team would be better able to provide information about that.
If you are able to get the User's username or ID from the Buddypress team using a shortcode, I can help you implement that information in a View of Events as a post author Query Filter, using a shortcode attribute to set the User dynamically. See the screenshot here showing how to configure a View's post author filter to accept a shortcode attribute. When a View of Events is configured this way, you can use a View shortcode to insert this View in your page template like so:
[wpv-view name="Your Events View" author="[buddypress-shortcode][/buddypress-shortcode]"]
If the Buddypress team cannot provide the Member ID or username using a shortcode, but can provide the information using a PHP API, I can show you how to use our Views PHP API to modify a View's post author query filter configurations using their PHP API. I would need to see an example of their PHP API that can provide the Member's username or ID to be able to help with that implementation.
Let me know if you need anything from me to help facilitate that conversation with their support team, or if I have misunderstood what you want to achieve.
I searched around here and didn't get any shortcode. What I got was this code that I don't know how I can use it.
<? php echo bp_displayed_user_id (); ? >
I found this article that seems to explain it well, but I don't know where or how to work with these codes
hidden link
Okay great, let's see if that function gives us the necessary information. Please add this code to your child theme's functions.php file, or create a new custom code snippet in Toolset > Settings > Custom Code tab and add the code there:
// custom shortcode to return displayed BP Member's user ID
add_shortcode( 'tssupp-get-bp-member-user-id', 'tssupp_get_bp_member_user_id_func');
function tssupp_get_bp_member_user_id_func($atts)
{
if( function_exists('bp_displayed_user_id')){
return bp_displayed_user_id();
}
return null;
}
If you create a new snippet in Toolset > Settings > Custom Code, set the snippet to run everywhere and activate the snippet.
Then edit the template for the Member Events page and place the custom shortcode in that template like this:
BP Member User ID: [tssupp-get-bp-member-user-id][/tssupp-get-bp-member-user-id]
After that, test the Events page for various Members. If the shortcode returns the correct User ID for each Member, we have the information we need. I'll show you how to proceed with this information.
Vou tentar seguir as dicas e posto o resultado
Sorry, I don't understand your last comment. Would you like to continue discussing in English? If not, I can transfer this ticket to a Spanish speaking supporter.
It worked perfectly well. We managed to get the ID. Now I need to make the filter so that only the posts appear in which the author of the post = id we took.
I tried to put the shortcode in the filter but it didn't work. I believe we are close.
Let's go to Google translator because you are a genius.
See if I'm on the right track?
I try to put the shortcode in the filter but the error message appears.
I try to put the shortcode in the filter but the error message appears.
You should not add the shortcode here. Instead, you should replace the text "author" in the filter settings.
Next, go to Toolset > Settings > Front-end Content and add "tssupp-get-bp-member-user-id" in the "Third-party shortcode arguments" field. This will allow us to use the custom shortcode in a View shortcode.
Next, you must insert the View in your template using a shortcode and set the author attribute like this:
[wpv-view name="your-view-slug" author="[tssupp-get-bp-member-user-id][/tssupp-get-bp-member-user-id]"]
Replace your-view-slug with the slug of this View, or the name of the View.
My issue is resolved now. Thank you!