Try:
$href = site_url() . '/members/?s=' . bp_member_profile_data( 'field=Country' ) . '&members_search_submit=Search';
sorry I’m new in php.
You mean
<?php if ( $href = http://www.mysite.com() . '/members/?s=' bp_get_member_profile_data( 'field=Country' ). '&members_search_submit=Search'; ) : ?>
?
<?php
$country = bp_get_member_profile_data( 'field=Country' );
if ( $country != false ) {
$href = site_url() . '/members/?s=' . $country . '&members_search_submit=Search';
echo '<a href="' . $href . '">' . $country . '</a>';
}
?>
Thanks ! It’s clickable now but the link goes to 404 error
Ok. I just solve it. Thanks again !
Here’s another approach, as we going to use an external function instead of modifying the template.
Add this to bp-custom.php
function clickable_countries_on_member_directory() {
// is xprofile component active ?
if ( bp_is_active( 'xprofile' ) ) {
if ( $mycountry = xprofile_get_field_data( 'Country', bp_get_member_user_id() ) ) :
$search_url = add_query_arg( array( 's' => urlencode( $mycountry ) ), bp_get_members_directory_permalink() );
echo '<br/><div class="my_country"><a href="' . esc_url( $search_url ) . '" rel="nofollow">' . $mycountry . '</a></div>';
endif;
}
}
add_filter ( 'bp_directory_members_item', 'clickable_countries_on_member_directory' );
thanks.
Now it’s working but for one field I’m using multiselector field,
so when I click, it search for the 2 jobs at the same. What I would like is to search for only 1 job at the time
Try this (untested)
function clickable_job_on_member_directory() {
if ( bp_is_active( 'xprofile' ) ) {
$user_id = bp_get_member_user_id();
$myjob = xprofile_get_field_data( 'Job', $user_id );
if ( $myjob == 'vendor' ) :
$search_url = add_query_arg( array( 's' => urlencode( $myjob ) ), bp_get_members_directory_permalink() );
echo '<br/><div class="my_job"><a href="' . esc_url( $search_url ) . '" rel="nofollow">' . $myjob . '</a></div>';
endif;
if ( $myjob == 'analyst' ) :
$search_url = add_query_arg( array( 's' => urlencode( $myjob ) ), bp_get_members_directory_permalink() );
echo '<br/><div class="my_job"><a href="' . esc_url( $search_url ) . '" rel="nofollow">' . $myjob . '</a></div>';
endif;
if ( $myjob == 'secretary' ) :
$search_url = add_query_arg( array( 's' => urlencode( $myjob ) ), bp_get_members_directory_permalink() );
echo '<br/><div class="my_job"><a href="' . esc_url( $search_url ) . '" rel="nofollow">' . $myjob . '</a></div>';
endif;
}
}
add_filter ( 'bp_directory_members_item', 'clickable_job_on_member_directory' );
thanks. The issue is that in my list there is more than 100 different jobs…
And what is the problem ? Or you add 150 if....
or much simplier, don’t use a list and let each user enter his job manually instead of let him choose it from a list.
Ok, I will do the 150 if 😉
Thank so much again for the help !
…
$myjob = xprofile_get_field_data( 'Job', $user_id );
if ( is_array( $myjob ) ) {
foreach( $myjob as $job ) {
$search_url = add_query_arg( array( 's' => urlencode( $job ) ), bp_get_members_directory_permalink() );
echo '<br/><div class="my_job"><a href="' . esc_url( $search_url ) . '" rel="nofollow">' . $job . '</a></div>';
}
}
else {
$search_url = add_query_arg( array( 's' => urlencode( $myjob ) ), bp_get_members_directory_permalink() );
echo '<br/><div class="my_job"><a href="' . esc_url( $search_url ) . '" rel="nofollow">' . $myjob . '</a></div>';
}
I just try your solution shanebp but still goes to
http://www.mysite.com/?s=JOBA%2C+JobB