Form::duplicate_metadata_for_form( int $form_id )

Duplicates all metadata for this form and attaches it to another given form.

Description

See also

Parameters

$form_id

(int) (Required) New form ID to attach the metadata to.

Source

File: src/db-objects/forms/form.php

	protected function duplicate_metadata_for_form( $form_id ) {
		$forbidden_meta = array( '_edit_lock', '_edit_last' );

		$meta = get_post_meta( $this->original->ID );
		foreach ( $meta as $meta_key => $meta_values ) {
			if ( in_array( $meta_key, $forbidden_meta, true ) ) {
				continue;
			}

			foreach ( $meta_values as $meta_value ) {
				$meta_value = maybe_unserialize( $meta_value );

				add_post_meta( $form_id, $meta_key, $meta_value );
			}
		}
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.