简体   繁体   English

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

[英]Overriding user edit profile form

Im using theme_user_profile_form($form) and putting in the line 我正在使用theme_user_profile_form($form)并放入行中

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 我要做的就是删除用户个人资料编辑表单的某些部分,例如主题选择,时区等

The easiest way to do it, is to use hook_form_alter . 最简单的方法是使用hook_form_alter This needs to be in a custom module and not in your theme. 这需要在自定义模块中,而不是您的主题中。

The best thing is that you have to do that hook form alter, but do the unset in the after build of the form ie 最好的事情是,您必须更改钩子表单,但是要在表单的后续构建中进行未设置,即

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM