The mistake is with this line:
// Add the school ID as a meta data
add_user_meta( $user_id, 'school_id', [$school_id] );
No need for the array brackets when you store the user meta, change it to:
// Add the school ID as a meta data
add_user_meta( $user_id, 'school_id', $school_id );
Related Posts:
- How to order users by a date in the meta_value array
- How to get its meta_value of a specific meta_key within wp_usermeta
- How to display checkbox meta array values one by one?
- add_user_meta() vs update_user_meta()
- Problem storing arrays with update_user_meta
- wp_get_current_user always returns 0
- how to get specific fields from get_user_meta()
- Validating a new user registration field
- User meta to post
- Is there a limit to the length/size of serialized data that can be stored as user meta?
- very last action before during user registration before he is redirected to homepage
- Customizing WP tables or adding new ones?
- How to Make admin Sidebar Menu always be Collapse by code
- get_users / WP_User_Query returns empty when logged out
- update_user_meta adding new rows in db for same key
- What is the meta-box-order_post_hash used for?
- Add a member number to new user
- Get user’s ID on logout
- How to get the user description with get_users?
- get current user not working
- Getting $user_id for the_author_meta outside the loop in multisite
- No first_name or user_firstname property in WP_User object
- How to insert new element to existing array in usermeta?
- Store user’s registration date as meta
- Showing all users who match 2 meta fields with current user
- update_user_meta() not working
- How to display user’s avatar on their profile page?
- Get an array of meta_values for a user meta_key
- WP_user_query throws a 404 error
- Incrementally add or substract from usermeta field
- Is it possible to read a result if wp_update_user or update_user_meta fails?
- How to redirect on login to a specific page if a specific meta user is empty
- set a user-meta key as avatar
- Prevent update of custom user profile meta field on the front end after 1st entry
- User last login and user last visit problem
- update_user_meta after wordpress in action hooks
- Adding user data to an existing user_id
- Problem to wp_hash
- trying to determine if meta value exists for user and if not auto submit gravity form to redirect
- get_user_meta returning old data
- Why does the usermeta table contain html entities?
- get_user_meta returning empty when it’s NOT empty
- How can I programmatically show a specific (template) page, like author.php?
- WP_User_Query not returning users with meta – what am I missing?
- Multiple meta values for one meta key
- When is a user’s meta data table loaded?
- Display and Update User Custom Meta via user-edit.php
- Multiple Email Addresses, One User
- WordPress REST API and User meta data
- Randomize Users
- Get user_meta values for a user for an array of meta_keys?
- Displaying field value in new column in users view on wordpress
- “Select your country” landing page. Remember user choice
- How get meta from all users?
- Update user meta without lose of old data
- How can I undo accidentally duplicated user metadata key values?
- Test if key is in user_meta array
- How to add to a user_meta field (append)
- editing usermeta when field is an array
- How to order custom fields in the user profile (admin area)
- If logged in user views his profile page
- Add additional Fields for users and get value
- Getting a users username in get_user_meta
- Updating user meta on save post
- How do i put in user id in a banner
- Update user meta array using foreach
- Can’t get the user_meta correctly
- How to save a label for an extra user meta field and to display it later?
- Display user meta data from a textarea as a formated text
- get random users each time based on the meta key
- How $_GET[‘updated’] variable is passed when updating a user?
- Wrong result in fetching User meta of WordPress
- How to display user_meta array as a table?
- how to get users with usermeta include array of an array
- Delete user meta ( delete_user_meta ) by key without user id
- Why is my Custom User Meta deleted on Profile Update?
- How can I return an error message when updating user meta?
- Edit a user profile field on front end
- how to save multiple checkbox in usermeta and get it?
- How to set a user meta key value based on another user meta key value
- How to get value from radio buttons meta box, and return different contents?
- Using wp_login vs login_redirect to redirect based on user-meta
- Saving an array of values (file urls) to update_user_meta()?
- update_user_meta inside a popup/modal
- User biographical information erased on login
- How to delete only user meta value (not key) from usermeta table in wordpress?
- If logged in user meta is
- Get meta value and associated user meta
- Store Foreach in user profile
- WP Cron: Save third party data as user meta
- Reordering fields in registration form via custom plugin
- use single form to enter multiple profiles
- Allow users to create and store data and retrieve it on login
- How to access User meta data within a plugin
- user profile replace first name last name with custom values
- WPML – how to translate user profile fields with icl_t()? [closed]
- Creating a Digital Download facility and track downloads [closed]
- Find matches of a variable in custom usermeta
- get user id from custom user meta key
- Query a meta key using an array of values where the database value is a string