Autolink not working
-
I have two fields which I disabled Autolink for. on te members page these fields appear as links to non-existent search pages. I’d like these fields not to be linked. any ideas way the auto link feature isn’t working or how to turn it off?
I’ve tried creating a bp-custom.php and using this code:
<?
add_action( ‘init’, ‘remove_xprofile_links’ );
function remove_xprofile_links() {
remove_filter( ‘bp_get_the_profile_field_value’, ‘xprofile_filter_link_profile_data’, 9, 3 );
}
?>With no effect.
any help would be appreciated.
-
Hi,
Can you please tell me which field types it is happening for? I can look into it and check for the issues/solution.Thank you
BrajeshGood Morning Brajesh,
Thank you for the quick reply. Both Fields are Custom Taxonomy Multi-selector field type. Thanks for the help
Patricia
I can confirm the only fields that have links are the multi-selector fields. All other x-profile fields are link-less. I’m not sure how to fix this. Any ideas?
Hi,
I am sorry for the inconvenience.It might be possible that I have overlooked the settings for taxonomy/posts.
Please allow me to provide you with an update by Monday.
Thank you
BrajeshGood Evening,
Thank you for looking into this for me.
Sincerely
Patricia
Good evening Patricia.
Thank you for the prompt reply. I sincerely appreciate your patience.Regards
BrajeshHi Patricia,
Thank you for the patience.I have looked at it now.
When you disable the autolink, the terms are linked to their archive page. It is the implemented behaviour for the terms in this plugin.
Is there a chance that taxonomy that you are allowing to be selected does not have archive?
Good Morning @sbrajesh
I’m not sure if the terms have an archive page of not. I’m guessing not since the link results in a “nothing found” page. The fields that I’m having are all created using the BuddyPress Xprofile Custom field type plugin. I’m using the Custom Taxonomy Multiselector field type to populate a dropdown which an user can select multiple fields. I want to turn off the links since the linked fields result in a not found page. Any other field that had been previous lined with the exception of the member’s name is no longer linked.
I have a related problem with the autolink functionality for Custom Taxonomy Multiselector and Custom Post Multiselector also.
I would like the autolink to be enabled however this should perform a search of the members directory.
Instead I get a broken html list printed to the screen.
Looking at the ‘display_filter’ function in both classes (class-field-type-multi-select-taxonomy.php and class-field-type-multi-select-post-type.php) neither check to see if autolink is enabled or not and neither has any code to make the items a click through to a search query of the members directory.
Code from the original plugin is as below:
/** * 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); }
Doing a search for “bpxcftr-multi-taxonomy-terms-list” on Google brings back a single live site which demonstrates the issue…
https://puppy.pics/members/yorkielife/profile/
Dog Name: Zuzi
The word ‘Zuzi’ is hyperlinked to: https://puppy.pics/members/?members_search=Zuzi
The site obviously uses your plugin and the section for breed show the problem:
Breed:
<ul class='bpxcftr-multi-taxonomy-terms-list'><li><a href="https://puppy.pics/rt_dog-breeds/yorkshire-terrier/">Yorkshire Terrier</a></li></ul>
This should be:
Breed: Yorkshire Terrier
hyperlinked to https://puppy.pics/members/?members_search=Yorkshire+Terrier
Hope that makes sense!
Hi @magland
My recommendation is to disable autolink(which should be default) and it will link to the archive page of the taxonomy terms correctly. If you enable autolink, BuddyPress will cause problems with it.Also, the multi taxonomy field is not searchable. The values are stored as serialised ids which make it a bad candidate for search.
As far the site linked above, They have enabled auto link, if the disable it for the specific field, It will work as expected.
Regards
BrajeshThank you for the reply, however I disagree.
If auto link is disabled the values should display as text, not as links to the taxonomy archive. Alternatively this should be an option however the expected behaviour is just text.
If autolink is enabled they should be searchable.
While it may not be ideal in terms of search query performance the functionality exists in the backend to make them autolink therefore that functionality should be implemented on the front end. The plugin is not fully compatible with buddypress, not the other way around.
Currently enabling autolink breaks the site by outputting escaped html.
Hi,
I do agree with you that the behaviour of auto link is inconsistent based on what BuddyPress does.
What I do hope that we should change is when auto link is enabled, not what it links to. If it is not enabled, Link to plain text(term name as you mentioned).Linking arbitrary terms to members directory does not make sense. You can use normal multiselect or checkbox field to achieve the same serchable behaviour if you need it.
The purpose of term is to organize contents and not users. Why will a taxonomy term link to member directory search and not to the term archive, does not make sense to me(I may be incorrect in my assumptions, please help me understand the use case better).
If your goal is to categorize users, I will suggest BuddyPress Member Types( We have a free BuddyPress Member Types generator plugin).
I will fix the behaviour of auto link in next update.
Thank you
BrajeshPlease allow me till tomorrow to put a fix for the auto link behaviour.
Thank you
BrajeshIt’s really quite simple, in my case I have two taxonomies that store terms for ‘interests’ and ‘skills’, and one post type that stores work locations. My members are able to select multiple terms from for example skills and have them display on their profile.
The idea behind making them searchable is that they can then click the skill and find other members with the same skill or interest.
Equally for post type they can click on the location or building name and find other members that also work there.
Post types and taxonomies are ideal candidates for storing this info, Member types would not be suited in this instance. Neither would standard multiselect or checkboxes.
- The topic ‘Autolink not working’ is closed to new replies.