Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
For some reason, I can't use hook_form_alter on the user_register form. Is there something different that needs to be done when using content profile? Just to test, I did this:
function cmr_form_alter (&$form, $form_state, $form_id) {
drupal_set_message($form_id);
}
Every single form on the website is outputting a form id (even the edit profile form) but not the user register form. Help!
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commented+1
Comment #2
jamiehollernI've made some progress on this. By emptying caches I've managed to print the form array for user_register but this is a very small form and not what I'm looking for. Then, I tried to print the node form that the content profile is based on and voila, it printed. However it hasn't printed everything so I can't see the whole array.
Comment #3
jamiehollernApologies, but it seems that my progress was not what I thought it was. I'm back at square one. I've tried to use hook_form_alter to add a new validation function but it won't work on user sign up. A nudge in the right direction would be much appreciated.
Comment #4
jamiehollernBump. This is really starting to get frustrating. I have a perfectly good function that needs to run in order for my site to work properly and this stupid module is ensuring that it is impossible to do. Could one of the developers please just point me and everyone else who has this problem in the right direction? Why does hook_form_alter not affect a content profile registration form? How do you override this behaviour? I'm doing everything right but this module behaves in a way that obstructs other modules.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedPlease help us. Same problem here ;(
Comment #6
grendzy CreditAttribution: grendzy commentedcontent_profile_registration is installed with a system weight of 1 - so if you need your alter hooks to run after content_profile you'll need to adjust the weight of your custom module to something higher than 1. See http://drupal.org/node/110238
Comment #7
jamiehollernThanks very much for this, it's a good start. In my case, I am trying to alter values before they are submitted to the database but after the content profile registration form has been rendered. I'm unsure how to approach this, as I need my submit function to run before the data hits the database, but I'm not sure when $form_state['content_profile_registration'] is created.
I have tried to alter my $form_state in a [#submit] function that I array_unshift to be the first that runs but for some reason, $form_state['content_profile_registration'] still doesn't contain my altered values, even though $form_state['values'] contains the altered values.
Can anyone tell me the best way to (cleanly) alter these values before node_save is called?
Comment #8
baaj CreditAttribution: baaj commentedHey, I'm trying to do much the same thing. Were you able to figure this out?
Thanks!