user_contactmethods
筛选器获取两个参数,您将忽略它们。
正确的代码应为
add_filter(\'user_contactmethods\', \'contactmethods\',10,2);
function contactmethods($methods,$user){
global $wpdb;
$id = $user->ID;
$table = $wpdb->prefix . "table";
$myrows = NULL;
$myrows = $wpdb->query($wpdb->prepare(\'SELECT 1 FROM \' . $table . \' WHERE id = %d LIMIT 1\', $id));
if($ba_myrows == 1){
$user_contactmethods[\'option\'] = \'link\';
}
return $user_contactmethods;
}