我正在尝试替换插件中角色的硬编码下拉列表。目前代码如下:
echo \'<select name="xf_user_role_\' . $id . \'" id="xf_user_role_\' . $id . \'">\';
?>
<option value=\'subscriber\'
<?php echo ($xf_options[\'xf_user_role\'][$id] == \'subscriber\') ? "selected=\'yes\'" : \'\'; ?> >Subscriber</option>
<option value=\'contributor\'
<?php echo ($xf_options[\'xf_user_role\'][$id] == \'contributor\') ? "selected=\'yes\'" : \'\'; ?> >Contributor</option>
<option value=\'author\'
<?php echo ($xf_options[\'xf_user_role\'][$id] == \'author\') ? "selected=\'yes\'" : \'\'; ?> >Author</option>
<option value=\'editor\'
<?php echo ($xf_options[\'xf_user_role\'][$id] == \'editor\') ? "selected=\'yes\'" : \'\'; ?> >Editor</option>
<option value=\'administrator\'
<?php echo ($xf_options[\'xf_user_role\'][$id] == \'administrator\') ? "selected=\'yes\'" : \'\'; ?> >Administrator</option>
</select>
此代码更改为:echo \'<select name="xf_user_role_\' . $id . \'" id="xf_user_role_\' . $id . \'">\';
wp_dropdown_roles( );
?>
</select>
下拉列表显示,但选择不会提供$xf\\u选项。。。The wp_dropdown_roles isn\'t well documented in the Codex page. 我尝试了几种不同的方法来将信息添加到()中,但没有做到正确。
()中的正确信息是什么?