【发布时间】:2015-08-15 09:11:50
【问题描述】:
我正在尝试从发布名为fiche_artiste 的自定义帖子类型的表单中完成 gmw 的地址字段。
我在自制插件中使用此代码:
function gmw_update_fiche_artiste_location( $pid ) {
// Si c'est une édition d'un Artiste existant
if ( false !== wp_is_post_revision( $pid ) )
return;
// Vérifie la sauvegarde //
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
//Vérifie les droit de l'utilisateur
if ( !current_user_can( 'edit_post', $pid ) )
return;
//Obtention de l'information du champs du formulaire "address"
$gmw_address = get_post_meta( $pid, 'address', true );
if ( empty( $address ) )
return;
//Appel le fichier update-location.php
include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );
//Verifie si la fonction existe
if ( !function_exists( 'gmw_pt_update_location' ) )
return;
//Crée un array à passer à la fonction
$gmw_args = array(
'post_id' => $pid, //Identifie le nouvelle article
'post_type' => 'fiche_artiste',
'address' => $gmw_address // L'adresse récupérée du champs adress
);
//Appelle la fonction
gmw_pt_update_location( $gmw_args );
}
//Execute la fonction à la création/mise à jour de l'article
add_action( 'gmw_pt_after_location_updated', 'gmw_update_fiche_artiste_location' );
但它不起作用。我名为 address 的自定义字段已正确填写,但本地化后未填写。
【问题讨论】:
-
如果您翻译这些 cmets 和/或删除对诊断此问题没有特别帮助的那些 cmets,这将对我们所有人都有帮助。