简体   繁体   中英

Overriding user edit 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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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