Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • @btees

    Participant

    Got it sorted.

    I set up a new search-form.php in my child theme:

    <div class="<?php bp_nouveau_search_container_class(); ?> bp-search" data-bp-search="<?php bp_nouveau_search_object_data_attr() ;?>">
    <form action="" method="get" class="bp-dir-search-form" id="<?php bp_nouveau_search_selector_id( 'search-form' ); ?>">
    <select onchange="this.form.submit()" id="<?php bp_nouveau_search_selector_id( 'search' ); ?>" name="<?php bp_nouveau_search_selector_name(); ?>">
    		  <option value="" disabled selected>Filter by Industry</option>
    		  <option value="">All</option>
      <?php  $result = $wpdb->get_results ( "SELECT * FROM wp_bp_xprofile_fields WHERE id='2'" );
      foreach ( $result as $print );
      $options = $wpdb->get_results ( "SELECT * FROM wp_bp_xprofile_fields WHERE parent_id='$print->id'" );
          foreach ( $options as $option )   { ;?>
        	
        <option class="<?php echo $option->name;?>" name ="field_<?php echo $print->id;?>_match_any[]"value="<?php echo $option->name;?>"><?php echo $option->name;?></option>
              <?php } ;?> 
    		</select>
    </form>
    </div>
    

    And then Ravi over at BuddyDev figured out how to change what the search applies to:

    // Activity Search by Category
    
    function buddydev_filter_activities_query_args( $r ) {
    
    	$searched_category = empty( $r[ 'search_terms' ] ) ? false : $r[ 'search_terms' ];
    
    	if ( ! $searched_category ) {
    		return $r;
    	}
    
    	$r['search_terms'] = false;
    
    	if ( empty( $r['meta_query'] ) ) {
    		$r['meta_query'] = array(
    			array(
    				'key'     => 'bpcat',
    				'value'   => $searched_category,
    			)
    		);
    	} else {
    		array_push( $r['meta_query'], array(
    			'key'     => 'bpcat',
    			'value'   => $searched_category,
    		) );
    	}
    
    	return $r;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'buddydev_filter_activities_query_args' );

    @btees

    Participant

    Hi @venutius thanks for the reply, it looks like the issue was with my theme. It’s templates for buddypress seem to be riddled with issues!

    @btees

    Participant

    I’ve achieved what I wanted. Most likely in an incredibly convoluted way.

    If anyone can see any glaring issues with my code please shout. I’m a ludite when it comes to querying databases, arrays, etc.

    // Create the array for post ids related to the users industry
    		
    	global $wpdb;
    	$industry = xprofile_get_field_data( 2, $user_id, false );
    	$metas = $wpdb->get_results ( "SELECT activity_id FROM wp_bp_activity_meta WHERE meta_value='$industry'" );
    	$metasjson = json_decode( json_encode($metas), true);
    	
    		
    	$newList = array();
    foreach($metasjson as $key=>$listItem) {
     $newList[$key] =  $listItem['activity_id'];
    
    } 

    Then I added the below to your $retval

    // Get Posts in Specified Category
    		array(
    			'relation' => 'AND',
    			array(
    				'column'  => 'id',
    				'compare' => 'IN',
    				'value'   => (array) $newList
    			)
    		),

    @btees

    Participant

    Hi @venutius, thanks for the reply.

    Sorry, I used that at first and then changed to meta_key and meta_value in a stupor after hours of not figuring it out.

    I feel like my issue may be figuring out how to properly nest the array values. It’s so frustrating because I feel like I’m always just on the cusp of it!

    So at the moment the start of my code looks like:

    $retval = array(
    		'relation' => 'OR',
    		 array(
    			'relation' => 'AND',
    			array(
    				'column'  => 'user_id',
    				'compare' => 'IN',
    				'value'   => (array) $friends
    			)
    		),
    		array(
    			'relation' => 'AND',
    		 array(
    		 'meta_query' => array(
    		'key'     => 'bpcat',
                    'value'   => 'image',
    				) 
    				)
    		),

    For the moment I’ve set the metavalue to the static value of ‘image’ to try to get my loop working before adding any further complexity

    @btees

    Participant

    Thanks for that @shanebp

    I’ve been trying to use something like the “Builds an Activity Meta Query to retrieve the favorited activities” part of that document combined with the feed merging solution offered in this thread:

    how to combine activity tabs to one

    But I can’t seem to wrap my head around it.

    I’ve been trying to add the meta_query to my $retval like this:

    array(  
            'meta_query' => array(
                array('meta_key' => 'bpcat',
    			'meta_key' => $industry))
    			
        ),

    Where $industry is a variable associated with the viewers account like:
    $industry = xprofile_get_field_data( 2, $user_id, false );

    But I’ve also run it with a fixed value for testing ( 'meta_key' => $industry ), no joy either

    @btees

    Participant

    Hi @venutius,

    I really like your code.

    I’ve been trying to a custom metavalue I created to your bp_activity_filter_all_activity_scope function.

    So far it looks like:

    $industry = xprofile_get_field_data( 2, $user_id, false );

     array(  
            'meta_query' => array(
                array('meta_key' => 'bpcat',
    			'meta_key' => $industry))
    			
        ),

    The activity posts can be tagged with an industry, then the aim is to have the activities show up in the feeds of people in that industry.

    @btees

    Participant

    Hi @djpaul. Thanks again for your help.

    The comments section in Awpcp is added to single ad page layout via the wordpress backend. It calls the comment section by placing $comments where you want the comment section to be.

    From the looks of it, the entire page that awpcp creates for listings doesn’t.

    This looks like integrating this may be a bit beyond me right now. I’m looking to hire a developer.

    I was looking to post in the bp jobs board here but it’s closed to new comments (it seems to be closed quite recently)

    Does anyone have a suggestion as to where I might post this?

    Thanks again for all your help.

    @btees

    Participant

    Hi @djpaul,

    Thanks a lot for that, now I’m getting somewhere!

    Neither mentions.min.js or mentions.js were loading on awpcp pages so I put the following in my footer:

    <?php if ( is_page( 4792 ) ): ?>
        <script type='text/javascript' src='http://mysite.com/wp-content/plugins/buddypress/bp-activity/js/mentions.min.js?ver=2.5.1'></script>
    <?php endif; ?>

    I also added the bp-suggests class to the textarea.

    I’m now getting suggestions on the input box which is a good start!

    But when the comments are posted they are still just appearing in plain text.

    Is there a css class that should be added to the comment container? Or would this be part of implementing the activity stream and notification integration?

    @btees

    Participant

    Thanks for the reply @henrywright. As much as I like awpcp for somethings, development seems to be very slow. I was hoping to hack the plugin but can’t seem to find any documentation on implementing @mentions in plugins. I’m likely not searching the right terms

Viewing 9 replies - 1 through 9 (of 9 total)
Skip to toolbar