robsward (@robsward)

Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • In reply to: Meta query in Views

    robsward
    Participant

    @robsward

    Hi!

    Since I only had three values, I used the following to get around the ‘OR’ issue:

    'meta_key' => '_bbps_topic_status',
    'meta_value' => '3',
    'meta_compare' => '!='

    However, I now have another question, which is that I want to exclude from this view posts whose last reply author’s role is not keymaster or moderator. I have this logic in a template file to help me style the author link:

    		$reply_post_id		= bbp_get_topic_last_active_id();
    
    		$reply_author_id 	= bbp_get_reply_author_id( $reply_post_id );
    
    		$reply_author_role 	= bbp_get_user_display_role( $reply_author_id );
    
    		if( $reply_author_role == "Moderator" || $reply_author_role == "Keymaster" ) {
    			$role = "moderator";
    		} else {
    			$role = "";
    		}

    What I’d like to do is roll this into the query to return a list of topics/threads whose status is not ‘3’, and whose last active user does not belong to either the Moderator or Keymaster groups. Not sure if this is even possible, since one seems like it requires the WP_Users_Query– perhaps I should create a separate meta_key/value pair for the last active user role?

    Thanks again

    In reply to: Meta query in Views

    robsward
    Participant

    @robsward

    Hi Stephen,

    Thanks so much for the thought-out response. I’ve done a bit more poking around and found that it isn’t necessarily the complexity of the query, but rather the ‘OR’ relation that returns everything. If I replace that OR with AND and use a different meta key for the second array (status is either 0,1 or 2), I get a good list of results.

    Is there another way to ask for an OR relationship between values of a single meta key?

    Thanks!

    Rob


    robsward
    Participant

    @robsward

    bump


    robsward
    Participant

    @robsward

    Thank you very much!


    robsward
    Participant

    @robsward

    Thanks for trying karjaw!


    robsward
    Participant

    @robsward

    There are a couple of issues with that code up there. Correct function is this one:

    public function forum_list(){
    
    	$forums		= array();
    
    	if ( bbp_has_forums() ) {
    		while ( bbp_forums() ) {
    
    			bbp_the_forum();
    
    			$forum_id = bbp_get_forum_id();
    			$forum_name = bbp_get_forum_title();
    			$data = array( 'ID' => $forum_id, 'name' => $forum_name );
    
    			$forums[] = $data;
    
    		} // while()
    	} // if()
    
    	return $forums;
    
    } // get_forum_list()
    In reply to: Get User Role from ID

    robsward
    Participant

    @robsward

    Got a bit closer doing this:

    $reply_author_role = bbp_get_reply_author_role( array( 'post_id' => bbp_get_topic_last_active_id() ) );

    However, I want just the role to be returned without the enclosing div so I can use it in a conditional.

Viewing 7 replies - 1 through 7 (of 7 total)