dozent_update_post_meta( int $post_id, string $meta_key, string|array|object $meta_value, string $prev_value = '' )

Updates a post meta field based on the given post ID. or delete existing meta if $meta_value is empty


Use the $prev_value parameter to differentiate between meta fields with the same key and post ID.

If the meta field for the post does not exist, it will be added and its ID returned.

Example usage:

dozent_update_post_meta( $post_id, $meta_key, $meta_value );

Can be used in place of add_post_meta().

See also



(int) (Required) Post ID.


(string) (Required) Metadata key.


(string|array|object) (Required) Metadata value. Must be serializable if non-scalar.


(string) (Optional) Previous value to check before updating.

Default value: ''


File: includes/core-functions.php

	function dozent_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
		if ( ! empty( trim( $meta_value ) ) ) {
			update_post_meta( $post_id, $meta_key, $meta_value, $prev_value );
		} else {
			delete_post_meta( $post_id, $meta_key );


Version Description
DozentLMS 1.0.0 Introduced.