62.3 F
Los Angeles
Thursday, November 21, 2024

Trump Lawyer Resigns One Day Before Trial To Begin

Joseph Tacopina has filed with the courts that he will not represent Donald J. Trump. The E. Jean Carroll civil case is schedule to begin Tuesday January 16,...

Judge Lewis A. Kaplan Issues Order RE Postponement

On May 9, 2023, a jury found Donald J. Trump liable for sexual assault and defamation. The jury awarded Ms. Carroll $5 million in damages. Seven months ago,...

ASUS Announces 2023 Vivobook Classic Series

On April 7, 2023, ASUS introduced five new models in the 2023 Vivobook Classic series of laptops. The top laptops in the series use the 13th Gen Intel® Core™...
StaffPenguin Flight LogThe current state of inserting user information into a WordPress database

The current state of inserting user information into a WordPress database

Writing PHP code is not easy for me. Easy ideas can be frustrating to complete. For example, inserting a new user into WordPress should be as simple as using the function wp_insert_user. An array is built and the information is inserted into the WordPress database. Only if it was that easy.

The XenWord plugin requires the ID of the user to match the XenForo member user_id. This means part of the array inserted into the WordPress database must be the ID. The WordPress developer site states the integer ID may be included in the array but the example provided on the page returns the newly created user_id. Most important, the page states, “If there is no ID, a new user will be created. If you pass an ID , the user with that ID will be updated.”

Since no user with that ID exists and the ID must be passed in the array, then wp_insert_user isn’t the best choice for adding the user information. Instead, an array is created and this information is added to the database by an insert command.

Once the information is added to the database then the role for the new user is added with the function set_role. Any meta information is added using the update_user_meta.

[pastacode lang=”php” path_id=”91c07754df8fe2580abb84586ce1b93a” file=”” highlight=”” lines=”” provider=”gist”/]

This is the only way I’ve found that works. Please let me know if you discover a better way to insert a new user into the database while passing the ID parameter.

LPH
Layne Heinyhttp://www.layneheiny.com
LPH is a high school physics teacher interested in the Apple iPad and iPhone, Microsoft Surface, Tablet PCs, and other mobile devices. He resides with one large dog who begs for pizza, hamburgers, French fries, and anything else on the dinner table.

Latest news

Related news