我有一个来自强大插件的定制钩子,它从一个字段获取值并将其复制到另一个字段。
更多细节https://formidableforms.com/knowledgebase/frm_validate_field_entry/#kb-change-the-value-in-a-field
代码按预期工作,但它没有返回字段的确切复制值,而是显示它的ID。
我试着用$_POST['item_meta'][140]替换get_the_title( $_POST['item_meta'][140] );,但是现在这个领域没有任何价值。
add_filter('frm_validate_field_entry', 'copy_my_field', 10, 3);
function copy_my_field($errors, $posted_field, $posted_value){
if ( $posted_field->id == 128 ) { //change 25 to the ID of the field to change
$_POST['item_meta'][$posted_field->id] = $_POST['item_meta'][140];
//Change 20 to the ID of the field to copy }
return $errors;
}谢谢。
发布于 2021-03-16 10:04:49
如果我理解你的问题,你的意思.$_POST['item_meta'][140]是要查找标题的帖子的帖子ID?
这是没有测试的,但是如果$_POST['item_meta'][140]是post ID,那么它将得到标题。
add_filter('frm_validate_field_entry', 'copy_my_field', 10, 3);
function copy_my_field($errors, $posted_field, $posted_value) {
if ($posted_field->id == 128) {
//get the post object from post ID
$post = get_post($_POST['item_meta'][140]);
$_POST['item_meta'][$posted_field->id] = $post->post_title;
}
return $errors;
}https://stackoverflow.com/questions/66634062
复制相似问题