Advertisement:

Author Topic: [SOLVED] 'before_user_register' hook not working?  (Read 503 times)

patrickFromCroatia

  • Sr. Member
  • ****
  • Posts: 363
  • qwertZ
[SOLVED] 'before_user_register' hook not working?
« on: July 08, 2018, 02:58:40 am »
Hello,

I've just installed new osclass demo site, bender theme, no changes, version 3.7.4. I'm trying to extend user form by adding custom attributes and I'm experimenting with various hooks. I came to 'before_user_register' hook and thought that I could use it to store $_POST values to session, but it looks like the hook is not firing. I tried various codes (look below) but none of them did nothing. The hook is called in oc-includes/osclass/controllers/register.php, but it doesn't seem to work.

Examples (all of them worked with different hooks):

Example 1 - preference:

Code: [Select]
<?php
function user_attributes_post() {
    return 
osc_set_preference('testing''testing''user_attributes');
}
osc_add_hook('before_user_register''user_attributes_post');
?>


Code: [Select]
<?php
function user_attributes_post() {
    
osc_add_flash_error_message_m('Oops!'));
    
osc_redirect_to(osc_register_account_url());
}
osc_add_hook('before_user_register''user_attributes_post');
?>


Does anyone know something about this?

EDIT: Thanks to @dev101, the hook works, it's just not called when adding users in admin (that's what I was doing).

Regards.
« Last Edit: July 08, 2018, 01:14:48 pm by patrickFromCroatia »

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 1978
  • osclass.work
Re: 'before_user_register' hook not working?
« Reply #1 on: July 08, 2018, 03:16:40 am »
Hi, I have tested this, both examples are working just fine, code you posted does exactly what you wanted/instructed.

patrickFromCroatia

  • Sr. Member
  • ****
  • Posts: 363
  • qwertZ
Re: 'before_user_register' hook not working?
« Reply #2 on: July 08, 2018, 11:41:06 am »
Thanks for replying, is the hook also called when posting in admin? I was testing it there.

Regards.

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 1978
  • osclass.work
Re: 'before_user_register' hook not working?
« Reply #3 on: July 08, 2018, 12:26:17 pm »
Of course not, that would limit admin :)

patrickFromCroatia

  • Sr. Member
  • ****
  • Posts: 363
  • qwertZ
Re: 'before_user_register' hook not working?
« Reply #4 on: July 08, 2018, 01:13:32 pm »
That makes sense... I was creating new users in admin instead default way because it was faster, that's why it didn't work. Thank you. ;)

Regards.