Skip to content

New user defaults never applied: ucp_register_set_data reads user_id from an event that doesn't provide it #196

Description

@avandenberghe

Summary

ucp_listener::ucp_register_set_data() subscribes to core.ucp_register_data_after and reads $event['user_id'] to UPDATE the new account's user_rt_* columns with the board-wide defaults.

core.ucp_register_data_after (triggered in includes/ucp/ucp_register.php) only ever provides submit, data, cp_data, error — no user_id. It also fires during form validation, before user_add() is called (user_id doesn't exist yet at that point in the request at all).

So (int) $event['user_id'] evaluates to (int) null = 0, and the UPDATE runs as:

UPDATE phpbb_users SET user_rt_enable = ..., ... WHERE user_id = 0

which updates no real row. New accounts keep whatever the user_rt_* columns default to at the schema level instead of the "new users inherit ACP defaults on registration" feature actually applying.

Location

avathar/recenttopics/event/ucp_listener.php:

  • getSubscribedEvents(): 'core.ucp_register_data_after' => 'ucp_register_set_data'
  • ucp_register_set_data($event): builds $sql_ary from config defaults, then WHERE user_id = ' . (int) $event['user_id']

Fix

Subscribe to core.ucp_register_register_after or core.user_add_after instead — both fire after user_add() succeeds and both provide a real user_id in the event data. core.ucp_register_register_after is triggered in includes/ucp/ucp_register.php with user_id explicitly in its vars list.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Eventbugv3.0Version 3.0.x - maintenance releases

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions