首页 文章

在Wordpress中隐藏字段新用户注册表单

提问于
浏览
-2

如何在位于wp-admin / user-new.php的Wordpress“新用户注册”表单中隐藏表单字段?我想隐藏ID为'first_name'和'last_name'的字段,因为我正在构建一个插件 .

我已经为这个表格做了一个扩展部分 . 但我想隐藏原始形式的字段 . 我想这样做的原因是因为在荷兰我们有一个像'Mike van den Hoek'这样的lastname_prefix,其中'van den'是前缀 . 我想将'first_name','lastname_prefix'和'last_name'的字段放入此表单的扩展部分而不是原始形式 .

我尝试使用jquery函数hide()并将此函数作为我想要隐藏的表单字段的id . 但不幸的是,这不起作用

1 回答

  • 0

    请将以下代码粘贴到您的插件php文件中 .

    add_action('admin_footer', 'remove_first_name_and_last_name');
    function remove_first_name_and_last_name() { 
    global $pagenow;
        if ($pagenow !='user-new.php') return;
    echo '<script>
        jQuery(document).ready(function(){
        jQuery(".user-new-php #first_name, .user-new-php #last_name").parent().parent().hide();
    });
    </script>';
    }
    

相关问题