Forum Replies Created

Viewing 15 replies - 31 through 45 (of 49 total)
  • Thread Starter magland

    (@magland)

    Thanks for your reply.

    As a compromise could it just be that post_title and or post_content is by default given a higher weight than all xprofile fields? For now I don’t think individual control of xprofile field weights is useful, just that post_title should be more influential.

    The relevanssi plugin does something like this:

    https://www.relevanssi.com/user-manual/installing-relevanssi-and-adjusting-the-settings/

    search weights

    I was able to get this working using template overrides at the following paths:

    child-theme-folder/buddypress-global-search/loop/member-ajax.php
    child-theme-folder/buddypress-global-search/loop/member.php

    (You don’t need to include the ‘templates’ folder.)

    My code to add extra info to the members template is like:

    		<div class="item-desc">
    			<?php
    			if(xprofile_get_field_data( 'Phone', bp_get_member_user_id() )) {
    				echo '<strong>Phone:</strong> ' . xprofile_get_field_data( 'Phone', bp_get_member_user_id());
    			}
    			if(xprofile_get_field_data( 'Phone', bp_get_member_user_id() )) {
    				echo '<br /><strong>Email:</strong> <a href="mailto:' . xprofile_get_field_data( 'Email', bp_get_member_user_id()) .'">' . xprofile_get_field_data( 'Email', bp_get_member_user_id()) . '</a>';
    			}
    			?>
    		</div> 

    e.g.

    xprofile_get_field_data( ‘X_PROFILE_FIELD_NAME_HERE’, bp_get_member_user_id())

    Can you override the individual sub templates?

    e.g.

    child-theme-folder/buddypress-global-search/templates/loop/member-ajax.php
    child-theme-folder/buddypress-global-search/templates/loop/member.php

    I want to add extra info into the members search.

    However it doesn’t appear to be working.

    It looks like there is provision for this as the template file includes some code that is commented out:

            <?php
             /***
              * If you want to show specific profile fields here you can,
              * but it'll add an extra query for each member in the loop
              * (only one regardless of the number of fields you show):
              *
              * bp_member_profile_data( 'field=the field name' );
              */
            ?>

    After further testing it seems that the notification stays in place even if it hasn’t been deleted. You can only mark it as read by going to your profiles notifications page and manually clicking read next to each one.

    The issue here is that the behaviour is different to other notifications.

    For example when someone comments on an activity and you get a notification, if you click the notification it takes you to the comment AND it automatically marks the notification as read.

    If you click on a reaction notification, it takes you to the reaction but doesn’t mark it as read.

    I’ve uploaded a screenshot to explain here:

    https://ibb.co/hpVg9k

    Thread Starter magland

    (@magland)

    This will be a great enhancement, looking forward to it.

    Thread Starter magland

    (@magland)

    Yes it appears to be fixed, thanks for looking into the issue.

    – After clicking on the number of “reactions” and it shows the list. Let me click on the user’s name and then take me to his profile.

    I added the following to my bp-custom.php and it makes the Usernames clickable through to their profile.

    add_action( 'init', 'changeActions' );
    function changeActions () {
    	remove_action('wp_ajax_ai_get_activity_reactions_list', 'ai_get_activity_reactions_list');
    	remove_action('wp_ajax_nopriv_ai_get_activity_reactions_list',  'ai_get_activity_reactions_list');
    	add_action('wp_ajax_ai_get_activity_reactions_list', 'custom_ai_get_activity_reactions_list');
    	add_action('wp_ajax_nopriv_ai_get_activity_reactions_list', 'custom_ai_get_activity_reactions_list');
    }
    function custom_ai_get_activity_reactions_list()
    {
    		GLOBAL $wpdb;
    		$result=array();
    		$html="<div class='ai_recent_reactions_list'><div class='ai_recent_reaction_users'><h5>Recent 10 users who reacted to this activity update</h5></div><ul>";
    		$activity_id = intval(str_replace("activity-","",$_REQUEST['activity_id']));	
            $table = $wpdb->base_prefix . 'arete_buddypress_smileys_manage';
    		$query_check = $wpdb->get_results("select * from $table where activity_id='$activity_id'");
    		if($query_check && $wpdb->num_rows <> 0)
    		{	foreach ($query_check as $user_check) {
    				$user_id=$user_check->user_id;
    				$reaction_id=$user_check->smiley_id;
    				$user_info  = get_userdata($user_id);
    				$username	= $user_info->user_login;	
    				$html.="<li><a href='".bp_core_get_user_domain( $user_id )."'>".$username."</a>".ai_get_single_reaction($reaction_id)."</li>";
    			}
    		}
    		$html.="</ul></div>";
    		
    		$result['html']=$html;
    		echo json_encode($result);
    		die();
    }
    
    Thread Starter magland

    (@magland)

    I believe it’s 2.2.4

    Thread Starter magland

    (@magland)

    Can I safely truncate the wp_wordpoints_user_ranks table also?

    Thread Starter magland

    (@magland)

    thanks for the info

    Thread Starter magland

    (@magland)

    Tough call. If it was in core I think people would use it, however some people would likely want to be able to turn it off, in which case an extension may make more sense. It’s 50/50 for me. Sorry that’s not helpful!

    Thread Starter magland

    (@magland)

    Hey, thanks for getting back to me. I’ve voted for the feature ??

    I’d be glad to help with development / testing of this particular feature if possible.

    Your plugin is great and I look forward to any future updates.

    I am also experiencing this problem. I think it’s because the activity that was liked was removed before the notification was read.

    Thread Starter magland

    (@magland)

    thanks, are you referring to: bp_compliments_start_compliment() ?

    I have located that function in bp-compliments-functions.php and can see it has the following params:

    @param string|array $args {
    * Attributes of the $args.
    *
    * @type int $receiver_id Received ID.
    * @type int $sender_id Sender ID.
    * @type int $term_id Compliment Icon Term ID.
    * @type int $post_id Post ID.
    * @type string $message The compliment Message.
    *
    * }

    What does $post_id refer to in this case?

    Is it the id of the compliment? How does that differ from $term_id?

    I’ve modified the code and it seems to work.

    Save this code as ‘BXcft_Field_Type_MultiSelectCustomTaxonomy_Custom.php’

    and include the file in your theme, for example:

    Add this to your themes functions.php

    require_once(‘inc/classes/BXcft_Field_Type_MultiSelectCustomTaxonomy_Custom.php’);

    <?php
       	class Bxcft_Field_Type_MultiSelectCustomTaxonomy extends BP_XProfile_Field_Type
        {
            const ALLOW_NEW_TAGS = "allow_new_tags";
    
            public function __construct() {
                parent::__construct();
    
                $this->name = _x( 'Custom Taxonomy Multiselector', 'xprofile field type', 'bxcft' );
    
                $this->supports_multiple_defaults   = true;
                $this->supports_options             = true;
    
                $this->set_format( '/^.+$/', 'replace' );
                do_action( 'bp_xprofile_field_type_multiselect_custom_taxonomy', $this );
            }
    
            public function admin_field_html( array $raw_properties = array() ) {
                $html = $this->get_edit_field_html_elements( array_merge(
                    array(
                        'multiple' => 'multiple',
                        'id'       => bp_get_the_profile_field_input_name() . '[]',
                        'name'     => bp_get_the_profile_field_input_name() . '[]',
                    ),
                    $raw_properties
                ) );
            ?>
                <select <?php echo $html; ?>>
                    <?php bp_the_profile_field_options(); ?>
                </select>
            <?php
            }
    
            public function admin_new_field_html (\BP_XProfile_Field $current_field, $control_type = '')
            {
                $type = array_search( get_class( $this ), bp_xprofile_get_field_types() );
                if ( false === $type ) {
                    return;
                }
    
                $class            = $current_field->type != $type ? 'display: none;' : '';
                $current_type_obj = bp_xprofile_create_field_type( $type );
    
                $options = $current_field->get_children( true );
                if ( ! $options ) {
                    $options = array();
                    $i       = 1;
                    while ( isset( $_POST[$type . '_option'][$i] ) ) {
                        if ( $current_type_obj->supports_options && ! $current_type_obj->supports_multiple_defaults && isset( $_POST["isDefault_{$type}_option"][$i] ) && (int) $_POST["isDefault_{$type}_option"] === $i ) {
                            $is_default_option = true;
                        } elseif ( isset( $_POST["isDefault_{$type}_option"][$i] ) ) {
                            $is_default_option = (bool) $_POST["isDefault_{$type}_option"][$i];
                        } else {
                            $is_default_option = false;
                        }
    
                        $options[] = (object) array(
                            'id'                => -1,
                            'is_default_option' => $is_default_option,
                            'name'              => sanitize_text_field( stripslashes( $_POST[$type . '_option'][$i] ) ),
                        );
    
                        ++$i;
                    }
    
                    if ( ! $options ) {
                        $options[] = (object) array(
                            'id'                => -1,
                            'is_default_option' => false,
                            'name'              => '',
                        );
                    }
                }
    
                $taxonomies = get_taxonomies(array(
                    'public'    => true,
                    '_builtin'  => false,
                ));
            ?>
                <div id="<?php echo esc_attr( $type ); ?>" class="postbox bp-options-box" style="<?php echo esc_attr( $class ); ?> margin-top: 15px;">
            <?php
                if (!$taxonomies):
            ?>
                    <h3><?php _e('There is no custom taxonomy. You need to create at least one to use this field.', 'bxcft'); ?></h3>
            <?php else : ?>
                    <h3><?php esc_html_e( 'Select a custom taxonomy:', 'bxcft' ); ?></h3>
                    <div class="inside">
                        <p>
                            <?php _e('Select a custom taxonomy:', 'bxcft'); ?>
                            <select name="<?php echo esc_attr( "{$type}_option[1]" ); ?>" id="<?php echo esc_attr( "{$type}_option[1]" ); ?>">
                                <option value=""><?php _e('Select...', 'bxcft'); ?></option>
                            <?php foreach($taxonomies as $k=>$v): ?>
                                <option value="<?php echo $k; ?>"<?php if ($options[0]->name == $k): ?> selected="selected"<?php endif; ?>><?php echo $v; ?></option>
                            <?php endforeach; ?>
                            </select>
                        </p>
                        <p>
                            <?php _e('Allow users to add new tags:', 'bxcft'); ?>
                            <input type="checkbox" name="<?php echo esc_attr( "{$type}_option[2]" ); ?>"
                                id="<?php echo esc_attr( "{$type}_option[2]" ); ?>" value="<?php echo Bxcft_Field_Type_MultiSelectCustomTaxonomy::ALLOW_NEW_TAGS; ?>"
                                <?php if (is_array($options) && isset($options[1]) && $options[1]->name === Bxcft_Field_Type_MultiSelectCustomTaxonomy::ALLOW_NEW_TAGS): ?> checked="checked"<?php endif; ?> />
                        </p>
                    </div>
            <?php endif; ?>
                </div>
            <?php
            }
    
            public function edit_field_html (array $raw_properties = array ())
            {
                $user_id = bp_displayed_user_id();
    
                if ( isset( $raw_properties['user_id'] ) ) {
                    $user_id = (int) $raw_properties['user_id'];
                    unset( $raw_properties['user_id'] );
                }
    
                // HTML5 required attribute.
                if ( bp_get_the_profile_field_is_required() ) {
                    $raw_properties['required'] = 'required';
                }
    
                $html = $this->get_edit_field_html_elements( array_merge(
                    array(
                        'multiple' => 'multiple',
                        'id'       => bp_get_the_profile_field_input_name() . '[]',
                        'name'     => bp_get_the_profile_field_input_name() . '[]',
                    ),
                    $raw_properties
                ) );
            ?>
                <label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php esc_html_e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
                <?php do_action( bp_get_the_profile_field_errors_action() ); ?>
                <select <?php echo $html; ?>>
                    <?php bp_the_profile_field_options( "user_id={$user_id}" ); ?>
                </select>
            <?php
            }
    
            public function edit_field_options_html( array $args = array() ) {
                $options        = $this->field_obj->get_children();
                $terms_selected  = maybe_unserialize(BP_XProfile_ProfileData::get_value_byid( $this->field_obj->id, $args['user_id'] ));
    
    			//print '<pre>1234';
    			//print_r($terms_selected);
    			//print '</pre>';
    			//exit;
    			
                $html = '';
                if ($options) {
                    foreach ($options as $option) {
                        if (Bxcft_Field_Type_MultiSelectCustomTaxonomy::ALLOW_NEW_TAGS !== $option->name) {
                            $taxonomy_selected = $option->name;
                            break;
                        }
                    }
                    if ( !empty($_POST['field_' . $this->field_obj->id]) ) {
                        $new_terms_selected = $_POST['field_' . $this->field_obj->id];
                        $terms_selected = ( $terms_selected != $new_terms_selected ) ? $new_terms_selected : $terms_selected;
                    }
                    // Get terms of custom taxonomy selected.
                    $terms = get_terms($taxonomy_selected, array(
                        'hide_empty' => false
                    ));
                    if ($terms) {
                        foreach ($terms as $term) {
                            $html .= sprintf('<option value="%s"%s>%s</option>',
                                        $term->name,
                                        (!empty($terms_selected) && (in_array($term->name, $terms_selected)))?'selected="selected"':'',
                                        $term->name);
                        }
                    }
                }
    
                echo apply_filters( 'bp_get_the_profile_field_multiselect_custom_taxonomy', $html, $args['type'], $terms_selected, $this->field_obj->id );
            }
    
            public function set_whitelist_values( $values ) {
                foreach ($values as $value) {
                    if (Bxcft_Field_Type_MultiSelectCustomTaxonomy::ALLOW_NEW_TAGS !== $value) {
                        $taxonomy_to_check = $value;
                        break;
                    }
                }
    
                $terms = get_terms( array(
                    'taxonomy' => $taxonomy_to_check,
                    'hide_empty' => false,
                    'fields' => 'id=>name',
                ) );
    
                if ( $terms ) {
                    $this->validation_whitelist = array_merge(
                        // Convert ids to strings for validation.
                        array_map( function($v) {
                            return "$v";
                        }, array_keys( $terms ) ),
                        array_values( $terms )
                    );
                }
    
                return $this;
            }
    
            /**
             * Modify the appearance of value. Apply autolink if enabled.
             *
             * @param  string   $value      Original value of field
             * @param  int      $field_id   Id of field
             * @return string   Value formatted
             */
            public static function display_filter($field_value, $field_id = '') {
    
                $new_field_value = $field_value;
    
                if (!empty($field_value) && !empty($field_id)) {
                    $field = BP_XProfile_Field::get_instance($field_id);
                    if ($field) {
                        $do_autolink = apply_filters('bxcft_do_autolink',
                            $field->get_do_autolink());
                        if ($do_autolink) {
                            $query_arg = bp_core_get_component_search_query_arg( 'members' );
                        }
                        $childs = $field->get_children();
                        if (!empty($childs) && isset($childs[0])) {
                            $taxonomy_selected = $childs[0]->name;
                        }
                        $aux = '';
                        $term_ids = explode(',', $field_value);
                        foreach ($term_ids as $tid) {
                            $tid = trim($tid);
                            $term = get_term_by('name', $tid, $taxonomy_selected);
                            if ($term && $term->taxonomy == $taxonomy_selected) {
                                if (empty($aux)) {
                                    $aux .= '<ul class="list_custom_taxonomy">';
                                }
                                $aux .= '<li>';
                                if ($do_autolink) {
                                    $search_url = add_query_arg( array(
                                        $query_arg => urlencode( $tid )
                                    ), bp_get_members_directory_permalink() );
                                    $aux .= '<a href="' . esc_url( $search_url ) .
                                        '" rel="nofollow">' . $term->name . '</a>';
                                } else {
                                    $aux .= $term->name;
                                }
                                $aux .= '</li>';
                            }
                        }
                        if (!empty($aux)) {
                            $aux .= '</ul>';
                        }
                        $new_field_value = $aux;
                    }
                }
    
                /**
                 * bxcft_multiselect_custom_taxonomy_display_filter
                 *
                 * Use this filter to modify the appearance of Multiselector
                 * Custom Taxonomy field value.
                 * @param  $new_field_value Value of field
                 * @param  $field_id Id of field.
                 * @return  Filtered value of field.
                 */
                return apply_filters('bxcft_multiselect_custom_taxonomy_display_filter',
                    $new_field_value, $field_id);
            }
        }
    ?>
Viewing 15 replies - 31 through 45 (of 49 total)