admin管理员组文章数量:1291188
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)
- Make "Phone" field searchable.
- hook "Phone" field's value to the "user_url" when user registering. Using "user_url" make the "phone" field's value become searchable.
- or setup a cronjob sync both fields hourly.
or others genius idea make it happen!
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)
- Make "Phone" field searchable.
- hook "Phone" field's value to the "user_url" when user registering. Using "user_url" make the "phone" field's value become searchable.
- or setup a cronjob sync both fields hourly.
or others genius idea make it happen!
Share Improve this question edited Jun 1, 2021 at 23:01 kengi asked May 31, 2021 at 18:45 kengikengi 11 bronze badge 5- What is the reason for needing to sync the phone field to the user URL? Are users aware you're sharing personally identifiable data with Firebase? And are you sure that copying the value to the user_url field won't expose this information? In many European countries and some US states this would be considered a data breach – Tom J Nowell ♦ Commented May 31, 2021 at 20:12
- @TomJNowell the reason for syncing the phone field to user URL is because the Wordpress user search function cannot search the external profile but the user URL field is searchable ,so that's why I'm trying to sync the field when user registering. For your concern , users is noticed for the use of their mobile number. – kengi Commented Jun 1, 2021 at 5:13
- 1 did you consider asking instead how to make the field searchable? You've fallen into the X Y Problem trap, instead ask how to solve your problem, not how to implement a proposed solution, and you'll get better answers – Tom J Nowell ♦ Commented Jun 1, 2021 at 8:24
- @TomJNowell I think you're right, the best solution is make the external profile field searchable in frontend, but isn't it much more difficult to modify Wordpress primitive search? no idea about that. I have been stuck at this problem few days already, its drive me crazy. – kengi Commented Jun 1, 2021 at 9:26
- The searchable columns of the user table are set by a filter developer.wordpress/reference/hooks/user_search_columns – Tom J Nowell ♦ Commented Jun 1, 2021 at 12:03
1 Answer
Reset to default 0You do not need to, instead add the user URL column to the list of searchable table columns
https://developer.wordpress/reference/hooks/user_search_columns/
Which includes a user contributed example that does this:
https://developer.wordpress/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.
本文标签: phpcopy fields value to another field
版权声明:本文标题:php - copy fields value to another field 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741526208a2383480.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论