bbPress

Simple, Fast, Elegant

bbPress support forums » Plugins

get_latest_topics_where code problem

(2 posts)
  • Started 1 year ago by davidbessler
  • Latest reply from ardentfrost
  • This topic is not a support question

No tags yet.

  1. When I use the following code in a plugin:
    function forum_restriction_get_topics_where_plugin( $where ) {
    if ( is_front() ) {
    $list_of_allowed_forums = "4,1";
    $where = "WHERE forum_id IN ('$list_of_allowed_forums') ";
    $where .= " AND topic_sticky <> 2 ";
    return $where;
    } else {
    return $where;
    }
    }
    add_filter ( 'get_latest_topics_where', 'forum_restriction_get_topics_where_plugin' );

    I expect it to list the topics belonging to forums with ID 4 and ID 1. Instead, it is only listing topics with forum 4. When I change them to (1,4) it only lists 1. It seems it is only seeing the first value in the string. Any ideas why?

    Posted 1 year ago #
  2. I'm not absolutely sure about this, but it seems that SQL will want you to be more explicit. You need to break up the list (4 and 1) and add different strings to the where. So, for the first add WHERE forum_id = 4 then do OR forum_id = 1. Every subsequent forum id query should also start with an OR.

    That's what I think at least. It's worth a shot :)

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.