Forum Replies Created

Viewing 4 replies - 46 through 49 (of 49 total)
  • I have this issue also.

    “The normal buddypress search will only work with ids but bp profile search will allow you to search by tags.”

    That’s not quite true.

    With the default set of xprofile fields if you choose multi select or checkboxes it generates links like this for the resulting autolink fields:

    https://www.mysite.com/people/?members_search=interest2

    ^ this works fine.

    However if I change the links generated by the taxonomy field from id to text it doesn’t work.

    What’s the difference?

    Thread Starter magland

    (@magland)

    The addition of the code below worked and means I can remove the ugly string_replace and pull in the meta value within my activity/entry.php

    		if ($bpfb_code) {
    			$content = !empty($_POST['content']) ? $_POST['content'] : '';
    			$content .= "\n{$bpfb_code}";
    			$content = apply_filters('bp_activity_post_update_content', $content);
    			$aid = $gid ?
    				groups_post_update(array('content' => $content, 'group_id' => $gid))
    				:
    				bp_activity_post_update(array('content' => $content))
    			;
    			global $blog_id;
    			bp_activity_update_meta($aid, 'bpfb_blog_id', $blog_id);
    			
    			// added by matt 26/04/2017
    			bp_activity_add_meta($aid, 'customClass', $customClass);
    			
    		}
    Thread Starter magland

    (@magland)

    Turns out my method doesn’t work, it only works when the activity is first posted and injected into the feed. If you then refresh the feed page my custom classes aren’t there anymore… ??

    Thread Starter magland

    (@magland)

    Within the function ajax_update_activity_contents in class_bpfb_binder.php there is already some logic I can use to detect image, video or link. I have added a custom variable here containing the class I want to use.

    		if (!empty($_POST['data'])) {
    			if (!empty($_POST['data']['bpfb_video_url'])) {
    				$bpfb_code = $codec->create_video_tag($_POST['data']['bpfb_video_url']);
    				
    				// added by matt 26/04/2017
    				$customClass = "activityplus_video";
    			}
    			if (!empty($_POST['data']['bpfb_link_url'])) {
    				$bpfb_code = $codec->create_link_tag(
    					$_POST['data']['bpfb_link_url'],
    					$_POST['data']['bpfb_link_title'],
    					$_POST['data']['bpfb_link_body'],
    					$_POST['data']['bpfb_link_image']
    				);
    				
    				// added by matt 26/04/2017
    				$customClass = "activityplus_link";
    			}
    			if (!empty($_POST['data']['bpfb_photos'])) {
    				$images = $this->move_images($_POST['data']['bpfb_photos']);
    				$bpfb_code = $codec->create_images_tag($images);
    				
    				// added by matt 26/04/2017
    				$customClass = "activityplus_images";
    			}
    		}

    Further down there is a code block where the activity/entry.php template is loaded and processed:

    		if ($aid) {
    			ob_start();
    			if ( bp_has_activities ( 'include=' . $aid ) ) {
    				while ( bp_activities() ) {
    					bp_the_activity();
    					if (function_exists('bp_locate_template')) bp_locate_template( array( 'activity/entry.php' ), true );
    					else locate_template( array( 'activity/entry.php' ), true );
    				}
    			}
    			$activity = ob_get_clean();
    			
    			// added by matt 26/04/2017
    			$activity = str_replace("class=\"activity activity_update", "class=\"activity ".$customClass." activity_update", $activity);
    		}

    I’ve used a simple string replace to add in my custom class and this works for now.

    Obviously this is not ideal as I have modified the core plugin files. I would be interested to know if there is a more elegant solution.

Viewing 4 replies - 46 through 49 (of 49 total)