sbmar (@sbmar)

Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • In reply to: Child CSS

    sbmar
    Participant

    @sbmar

    I threw all of my bbpress.css code into the bbpress.min.css file and it all became included at that point. Not sure I like that but at least it works…

    In reply to: Child CSS

    sbmar
    Participant

    @sbmar

    Yes it is… directly after the update the entire website changed becuase it was no longer referencing the bbpress.css file in my child theme…

    In reply to: Creating Custom Search

    sbmar
    Participant

    @sbmar

    I have added to a previous thread that has some of what you’re looking for but I have not been able to get it to work 100% yet… maybe you’ll have better success?

    Search by user

    In reply to: Search function

    sbmar
    Participant

    @sbmar

    Has anyone found a good solution for this?

    In reply to: Search by user

    sbmar
    Participant

    @sbmar

    I think I almost have this working on my site but I cannot get the form value for some reason:

    $username = $_GET['bbp_search_by_user'];

    If I type the value into the URL (/?bbp_search_by_user=someuser), then it works 100%… should be something silly, right?

    I also added a member drop-down so when someone is searching they can choose from a listing of members that have already created at least one reply:

    global $wpdb;
    
    $sql = "SELECT DISTINCT
    $wpdb->posts.post_author as id,
    $wpdb->users.display_name as name
    FROM
    $wpdb->posts
    INNER JOIN $wpdb->users ON $wpdb->posts.post_author = $wpdb->users.ID
    WHERE
    $wpdb->posts.post_type = 'reply' AND $wpdb->users.display_name <> ''
    ORDER BY
    $wpdb->users.display_name ASC";
    
    $result = $wpdb->get_results($sql, OBJECT);
    			
    echo "<select name=\"bbp_search_by_user\">";
    echo "<option value='ALL'>All Users</option>";
    echo "<option value='ALL'></option>";
    foreach ($result as $key => $value) {			  
       echo "<option value='" . $value->id . "'>" . $value->name . "</option>";
    }
    echo "</select>";

    Anyone know how to get the $_GET[‘bbp_search_by_user’]; to work?

    Here’s the code in my functions.php:

    /* ADD SEARCH BY USER FUNCTION */
    
    add_filter ( 'bbp_before_has_search_results_parse_args', 'ha_custom_search_by_username' );
     
    function ha_custom_search_by_username() {
    	//Get username from input on search page
    	$username = $_GET['bbp_search_by_user'];
    
    	$default_post_type = array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    	//check if empty
    	if(!empty($username) && $username != "ALL"){
    		//Make ID from username
    		$user = get_user_by('slug', $username);
    		$user_id = $user->ID;
    	$args['author'] = $user_id;	
    	}
    	$args['post_type'] = $default_post_type;
    	$args['orderby'] = 'date';
    	$args['posts_per_page'] = '5';
    	$args['ignore_sticky_posts'] = 'true';
    	$args['order'] = 'DESC';
    
    	return $args;
    }
Viewing 5 replies - 1 through 5 (of 5 total)