Add terms to new Media Library files.

Experimental Snippet 🧪

Code

Filename: gpml-auto-add-terms.php

<?php
/**
 * Gravity Perks // Media Library // Add terms to new Media Library files.
 * https://gravitywiz.com/documentation/gravity-forms-media-library/
 *
 * Experimental Snippet 🧪
 */
// Update "123" to your form ID and "4" to your GPML-enabled File Upload field.
add_action( 'gpml_media_data_123_4', function( $gpml_media_data ) {
	$terms                                     = array(
		'category' => array(
			'Red',
			'Green',
			'Blue',
		),
		'post_tag' => array(
			'Small',
			'Medium',
			'Large',
		),
	);
	$gpml_media_data['post_data']['tax_input'] = $terms;
	return $gpml_media_data;
}, 10, 2 );

Leave a Reply

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

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.