php 重力特权//填充任何内容//填充后期元作为选择

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 重力特权//填充任何内容//填充后期元作为选择相关的知识,希望对你有一定的参考价值。

<?php
/**
 * Gravity Perks // Populate Anything // Populate Post Meta as Choices
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 */
// Update "123" with your form ID; Update "4" with your field ID.
add_filter( 'gppa_input_choices_123_4', function( $choices, $field, $objects ) {

	$custom_field = str_replace( 'meta_', '', $field['gppa-choices-templates']['label'] );
	$meta         = get_post_meta( $objects[0]->ID, $custom_field );
	$choices      = array();

	foreach( $meta as $value ) {
		$choices[] = array(
			'text'  => $value,
			'value' => $value,
		);
	}

	return $choices;
}, 10, 3 );

以上是关于php 重力特权//填充任何内容//填充后期元作为选择的主要内容,如果未能解决你的问题,请参考以下文章