copy fields value to another field

I've make a custom field named Phone using buddypress xprofile plugin, but this field cannot be searched by Wordpress primitive searching engine, I found another field which is user_url this field is searchable.

The solution I'm looking for : (either one)

  1. Make Phone field searchable.
  2. hook Phone field's value to the user_url when user registering. Using user_url make the phone field's value become searchable.
  3. or setup a cronjob sync both fields hourly.

or others genius idea make it happen!

Topic sync functions php buddypress Wordpress

Category Web


You do not need to, instead add the user URL column to the list of searchable table columns

https://developer.wordpress.org/reference/hooks/user_search_columns/

Which includes a user contributed example that does this:

https://developer.wordpress.org/reference/hooks/user_search_columns/#comment-4605

add_filter( 'user_search_columns', 'wpdocs_filter_function_name', 10, 3 );
     
function wpdocs_filter_function_name( $search_columns, $search, $wp_user_query ) {
    $search_columns[] = 'user_url';
    return $search_columns;
}

With this, no syncing to a URL field is necessary.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.