覆盖用户编辑个人资料表单

发布于 2024-09-13 07:04:32 字数 271 浏览 2 评论 0原文

我使用 theme_user_profile_form($form) 并放入行

unset ($form['timezone']);

但它不会从我尝试的页面中删除该项目

theme_preprocess_user_profile_form

但它似乎不起作用。

我想要做的就是删除用户配置文件编辑表单的某些部分,例如主题选择、时区等

Im using theme_user_profile_form($form) and putting in the line

unset ($form['timezone']);

But it doesnt remove that item from the page

I try:

theme_preprocess_user_profile_form

but it doesnt appear to work.

All I want to do is remove some portions of the user profile edit form, such as theme select, timezone etc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神爱温柔 2024-09-20 07:04:32

最简单的方法是使用hook_form_alter。这需要位于自定义模块中,而不是在您的主题中。

The easiest way to do it, is to use hook_form_alter. This needs to be in a custom module and not in your theme.

我乃一代侩神 2024-09-20 07:04:32

最好的事情是,您必须执行该钩子表单更改,但在表单的构建后执行取消设置,即

function example_form_alter(&$form, &$form_state, $form_id) {
   $form["#after_build"][] = "example";
}

function example($form, &$form_state) {`
    //dpm($form); /*devel module dependency for looking for the correct object*/
    //unset
    return $form;
}

The best thing is that you have to do that hook form alter, but do the unset in the after build of the form i.e.

function example_form_alter(&$form, &$form_state, $form_id) {
   $form["#after_build"][] = "example";
}

function example($form, &$form_state) {`
    //dpm($form); /*devel module dependency for looking for the correct object*/
    //unset
    return $form;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文