You set the variable $user
before you created this user..
It should be like this and you need to check if the user already exists
$user = get_user_by("email", $email); // Its return you the user object
if($user) {
update_user_meta($user->ID, "quiz_scores", $score);
} else {
$user_id = register_new_user($email, $_SESSION["email"]);
update_user_meta($user_id, "quiz_scores", $score);
}
Related Posts:
- What’s the most efficient database method to add and query usermeta?
- Can’t save ajax value to database
- Extend the wp_users table
- $wpdb->update has finished saving trigger?
- Select Multiple meta_value from WP DB; Single Query
- Is it possible to store visitors IPs in wp_postmeta table?
- Which is more efficient? Using usermeta, or creating a new MySQL table?
- A field with dashes in the slug [closed]
- In what part of the WordPress core does the users table and usermeta table get joined?
- Modify Database in Multi-Site wp_usermeta table
- Best way to tell if a user account is active, using the database only
- Using GROUP CONCAT in my-sql query with wp_usermeta table
- Is it safe to delete unnecessary user metadata?
- How to replicate a user plugin made table value, to this user’s custom meta table value?
- WordPress Database Huge wp_usermeta Table
- How to Access wp_usermeta Data Immediately After a New User is Created
- What can I do when an outside party hacks into my weblog and changes my display name?
- AJAX wp-mysql running too slow
- Users table missing from Database [closed]
- Recovering the table wp_usermeta from users
- I cannot find the difference between these wp_capabilities values in wp_usermeta
- Buddypress avatar image in database [closed]
- Storing user submitted forms [closed]
- wp_insert_user not creating account correctly when ID is manually set
- Compare User meta_value with Product meta_value
- Best Practice? – Saving multiple Values as Serialized Data / Saving each Value per Row / Dedicated Table
- Join Query on WP_USERMETA Table
- how add more field to wp user and save it to database
- Move Non-WordPress users table to WordPress database
- generate PDF from member information
- How to get the id of recently registered user from database?
- update multiple user meta field based on another meta field
- get_user_meta and umeta_id
- Preventing concurrent update of data
- Calling update_user_meta inside of another function doesn’t work
- What is best for saving lot of extra detail of user?
- wp_usermeta key problem
- Query a meta key using an array of values where the database value is a string
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- Keeping WP database synced across multiple developers using git
- Staging sites, how do you manage synchronising updates in the DB?
- How to get the post publish date outside the loop?
- Using transients in conjunction with memcached
- How to define composite keys with dbDelta()
- Forcing nickname as display_name in custom edit profile template
- How to get site URL if database is disconnected?
- Showing content from another wordpress installation database in the page template loop?
- Multiple WP install with same users database
- Dynamic data in `wp_register_script` needed
- How to verify password outside WordPress?
- Weird issue with database migration and SSL links
- Single database for multiple instances
- Get all tags not just first 10 with wp api 2.0
- Should non-WordPress data get its own DB?
- Accidentally deleted active_plugins portion of the wp_options DB table
- delete post meta from db, even if does not exist?
- Output custom content not from the posts table?
- Reducing Database Query Time
- How can I get my wordpress password from an SQL file?
- How to have an external DB read and get data from my wordpress database
- Is there an atomic way to update_option in WordPress (to ensure data integrity)?
- How to populate custom field dropdown box based on prior selection?
- All text disappeared (seems to be a database problem) [closed]
- Unset session variable on page reload / setup but exclude AJAX
- How and where is wordpress adding mySQL content to database?
- restore a db after bad backup
- Best practice to import user base (subscribers) from one website to another?
- Some weird users in database
- How to delete a particular row in a database table
- Location of image metadata on my server
- Is it good practice to import/export a blog to test a redesign?
- Getting value from database table depending on field value
- Getting “Error Establishing a Database Connection” on localhost in new Mac OSX Lion environment
- Secure way to use name_save_pre?
- wpdb->insert not inserting first variable
- change the year on all of my custom post types?
- custom tables in wordpress Database? (can i just create them with sql?)
- New installation fatal error in 5.9.3 at edit or create entry
- Storing transients giving database error
- I want to replicate a wordpress website over multiple servers
- Displaying requested data from a the database in wordpress
- Accidently changed the GUID
- Is there anyway to split posts to different databases?
- wp-cli + valet: “Error establishing a database connection”
- local wordpress broke after changing URL
- Is it safe to add INDEX to a column in WordPress database?
- Restore Old Database Over Newer WP & Plugin Files
- Not sure what to do next to optimize
- Database structure for thousands of posts
- How do I find out from my database what version of WordPress I need?
- How to create a database table?
- Accessing content from third party as native posts in WordPress
- Extracted CSV as Array for Custom Query Loop
- Hang Up Followed By Can’t select database
- One WP Database outside localhost and two connections
- Fetch data from another site, but the same database
- Problems with plugin that fetches data from database with ajax
- Every time I update or install a plugin I get “Error Establishing a Database Connection in WordPress”
- Cant Connect to Database
- WordPress database connection failed, while mysql client is working [closed]