WordPress Codesnippets

add user metadata


This wordpress code allows you to add user meta data to a user. The function first gets the current value of the user meta data you are trying to add. If there is already a value there, it will update the user meta data with the new value. If there is no current value, the function will do nothing.

Was this code snippet helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmatically save post

This code creates a WordPress post with the values of the ‘post_title’ and ‘post_content’ variables. It sets the post status to ‘publish’ and the author

Read More »

Create order programmatically

This code creates a new post in the WordPress database with post type ‘shop_order’, post title ‘Order #12345’, post status ‘wc-processing’, and ping status ‘closed’.

Read More »