• Hello Dear WordPressers,

    I would like to allow the users of my website to filter the visible posts on my website’s homepage using a text-field on their personal BuddyPress account.

    Each user would therefore be able to enter a comma-separated list of keywords in their text-field. Only the posts containing one or many of these keywords would be displayed on the website’s homepage.

    In a language developers understand better, here’s what I want to do :

    IF [post] CONTAINS [user-keyword] THAN [post-visibility=TRUE];
    ELSE [post-visibility=FALSE];

    Do you know if there’s any existing plugin that could help me do that or how I could make it by myself?

    Thanks in advance!

    A. Mayer

    • This topic was modified 7 years, 10 months ago by antoinemayer.
    • This topic was modified 7 years, 10 months ago by antoinemayer.
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    What you want is really just a standard search query. You could effect such a search by just redirecting to your front page with ?s={search terms} appended to the site URL. You can avoid a redirect by altering the main query in a callback to the “pre_get_posts” action.

    In the callback, ensure the query is the main query and it’s a home page query with class methods. If both are true, set the “s” query var to the user’s search terms with yet another class method.

    The other piece of the puzzle is how to get the user’s search terms. That I could not tell you, I’m unfamiliar with BuddyPress. I’ll wager it’s in user meta somewhere. Try to find it in the DB using phpMyAdmin. If it’s not in user meta, there may be a BP table I’m unaware of that saves such data. If you have trouble finding it, try asking in the dedicated BP support forum. If it’s in user meta, you can retrieve it with get_user_meta() .

Viewing 1 replies (of 1 total)
  • The topic ‘Filter visible posts from user’s BP account’ is closed to new replies.