Answer the question
In order to leave comments, you need to log in
Drupal 8, how to get user ID?
Programmatically created a form.
After filling out and validating the form, you need to find out the user ID in order to add data to the database.
I don't understand how to do this.
global $user doesn't work. Writes that there is no such object
global $user called in
public function submitForm(array &$form, FormStateInterface $form_state) {
global $user;
$account = $user->uid;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question