【发布时间】:2012-11-23 10:16:37
【问题描述】:
我在前端用户个人资料上创建了一个下拉选择,其中包括所有自定义帖子类型的帖子。
在选择时它实际上并没有保存选择,它只是恢复到第一个选项。
我哪里错了?
这是我的 functions.php 文件中的代码:
add_action( 'personal_options_update', 'save_custom_profile_fields' );
add_action( 'edit_user_profile_update', 'save_custom_profile_fields' );
function save_custom_profile_fields( $user_id ) {
update_user_meta( $user_id, 'teampage', $_POST['teampage'], get_user_meta( $user_id, 'teampage', true ) );
}
add_action( 'personal_options', 'add_profile_options');
function add_profile_options( $profileuser ) {
$greeting = get_user_meta($profileuser->ID, 'teampage', true);
?><tr>
<th scope="row">Member of which Health Board?</th>
<td>
<select name="teampage" id="teampage" >
<?php $portfolioloop = new WP_Query( array(
'post_type' => 'board',
'post_status' => 'publish'
)); ?>
<?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ?>
<option id="Yes" <?php selected( $profileuser->teampage, 'Yes' ); ?>><?php echo the_title(); ?></option>
<?php endwhile; wp_reset_query(); wp_reset_postdata(); ?>
</select>
</td>
</tr><?php
}
我正在使用this tutorial。
【问题讨论】:
-
这是从后端工作的吗?您如何在前端显示用户配置文件编辑屏幕?
-
@NikolaIvanovNikolov 它位于前端,通过 Theme My Login 插件链接到后端。我就是不能让它更新两端!