您的代码确实有效。只是在调用xprofile\\u insert\\u field($xfield\\u args)之后,您正在声明$xfield\\u args;
应该是这样的
add_action(\'bp_init\', \'field_xprofile_twitter\');
function field_xprofile_twitter()
{
global $bp;
$xfield_args = array (
field_group_id => 1,
name => \'Twitter\',
can_delete => false,
field_order => 1,
is_required => false,
type => \'textbox\'
);
xprofile_insert_field( $xfield_args );
}