안녕하세요!
워드프레스 게시판 KBoard와 Ultimate Member 플러그인을 함께 사용중입니다.
사용자 등록 정보 수정을 위하여 UM Account 페이지에 탭을 추가하기위해 아래의 코드를 function.php 파일에 추가했습니다.
/**
* UM 어카운트 페이지
*/
/* create new tab */
add_filter('um_account_page_default_tabs_hook', 'MyCustomTab', 100 );
function MyCustomTab( $tabs ) {
$tabs[800]['MyCustomTab']['icon'] = 'um-faicon-pencil-square-o'; // tab icon
$tabs[800]['MyCustomTab']['title'] = 'My Custom Tab'; // tab title
$tabs[800]['MyCustomTab']['submit_title'] = 'Update'; // button text
$tabs[800]['MyCustomTab']['custom'] = true;
return $tabs;
}
/* make our new tab hookable */
add_action('um_account_tab__MyCustomTab', 'um_account_tab__MyCustomTab');
function um_account_tab__MyCustomTab( $info ) {
global $ultimatemember;
extract( $info );
$output = $ultimatemember->account->get_tab_output('MyCustomTab');
if ( $output ) { echo $output; }
}
/* Finally we add some content in the tab */
add_filter('um_account_content_hook_MyCustomTab', 'um_account_content_hook_MyCustomTab');
function um_account_content_hook_MyCustomTab( $output ){
ob_start();
$id = um_user('ID');
$output = '<div class="um-field">';
$names = array('user_nation100','user_experience'); // ADD THE META-KEYS HERE
$fields = array();
foreach( $names as $name ){
$fields[ $name ] = UM()->builtin()->get_specific_field( $name );
}
$fields = apply_filters('um_account_secure_fields', $fields, $id);
foreach( $fields as $key => $data ){
$output .= UM()->fields()->edit_field( $key, $data );
}
$output .= '</div>';
$output .= ob_get_contents();
ob_end_clean();
return $output;
}
/* ensure that the custom fields are updated when the account is updated */
add_action('um_account_pre_update_profile', 'getUMFormData', 100);
function getUMFormData(){
$id = um_user('ID');
$names = array('user_nation100','user_experience'); // ADD THE META-KEYS HERE
foreach( $names as $name )
update_user_meta( $id, $name, $_POST[$name] );
}
문제는 사용자가 개인 등록 정보를 성공적으로 수정하고나면 하단의 메타값들 (국적 "user_nation100", 경험 "user_experience")이 kboard 게시판 필드에서는 숫자 Option Values 0,1,2,3 등으로 변환되어 표기되는것입니다. (원래는 한국, 미국 이런식으로 출력되야합니다)
밑에는 실제 게시판 필드 스크린샷입니다.
https://imgur.com/o6BJt7p
밑에는 드랍다운 항목들의 option values 보여주는 CSS 입니다.
https://imgur.com/0WFjWQE
이 부분은 어떻게 해결해야될까요?
감사합니다!
안녕하세요~^^
코드만 보면 이상한 부분은 없으며 정상적입니다.
아래 이미지처럼 value 값이 중요합니다.
value 값이 저장되고, 출력되기 때문에 value 값을 바꿔주셔야 합니다.
그리고 KBoard(케이보드) 스킨에 적요된 코드로 올려주세요~
고맙습니다.
확인해주셔서 감사합니다. 문제는 value값들이 한국, 미국, 기타 이런식으로 정상적으로 출력이 안되고 대신에 1, 2, 3 이런식으로 출력이되버려서요.
Kboard default 스킨사용중이구요. list.php 코드를 첨부했습니다.
<div id="kboard-default-list">
<?php if($board->isWriter()):?>
<!-- 버튼 시작 -->
<div class="kboard-control">
<a href="<?php echo $url->getContentEditor()?>" class="kboard-default-button-small"><?php echo __('New', 'kboard')?></a>
</div>
<!-- 버튼 끝 -->
<?php endif?>
<!-- 로그인후 글쓰기 버튼 시작 -->
<div class="kboard-control2">
<a href="http://teamdxc.com/login-2/" class="kboard-default-button-small"><?php echo __('로그인후 글쓰기', 'kboard')?></a>
</div>
<!-- 로그인후 글쓰기 버튼 끝 -->
<!-- 게시판 정보 시작 -->
<div class="kboard-list-header">
<?php if(!$board->isPrivate()):?>
<div class="kboard-total-count">
<?php echo __('Total', 'kboard')?> <?php echo number_format($board->getListTotal())?>
</div>
<?php endif?>
<div class="kboard-sort">
<form id="kboard-sort-form-<?php echo $board->id?>" method="get" action="<?php echo $url->toString()?>">
<?php echo $url->set('pageid', '1')->set('category1', '')->set('category2', '')->set('target', '')->set('keyword', '')->set('mod', 'list')->set('kboard_list_sort_remember', $board->id)->toInput()?>
<select name="kboard_list_sort" onchange="jQuery('#kboard-sort-form-<?php echo $board->id?>').submit();">
<option value="newest"<?php if($list->getSorting() == 'newest'):?> selected<?php endif?>><?php echo __('Newest', 'kboard')?></option>
<option value="best"<?php if($list->getSorting() == 'best'):?> selected<?php endif?>><?php echo __('Best', 'kboard')?></option>
<option value="viewed"<?php if($list->getSorting() == 'viewed'):?> selected<?php endif?>><?php echo __('Viewed', 'kboard')?></option>
<option value="updated"<?php if($list->getSorting() == 'updated'):?> selected<?php endif?>><?php echo __('Updated', 'kboard')?></option>
</select>
</form>
</div>
</div>
<!-- 게시판 정보 끝 -->
<!-- 카테고리 시작 -->
<?php
if($board->use_category == 'yes'){
if($board->isTreeCategoryActive()){
$category_type = 'tree-select';
}
else{
$category_type = 'default';
}
$category_type = apply_filters('kboard_skin_category_type', $category_type, $board, $boardBuilder);
echo $skin->load($board->skin, "list-category-{$category_type}.php", $vars);
}
?>
<!-- 카테고리 끝 -->
<!-- 리스트 시작 -->
<div class="kboard-list">
<table>
<thead>
<tr>
<td class="kboard-list-uid"><?php echo __('Number', 'kboard')?></td>
<td class="kboard-list-title"><?php echo __('Title', 'kboard')?></td>
<td class="kboard-list-user"><?php echo __('Author', 'kboard')?></td>
<td class="kboard-list-nation"><?php echo __('국가', 'kboard')?></td>
<td class="kboard-list-experience"><?php echo __('경험', 'kboard')?></td>
<td class="kboard-list-date"><?php echo __('Date', 'kboard')?></td>
<td class="kboard-list-vote"><?php echo __('Votes', 'kboard')?></td>
<td class="kboard-list-view"><?php echo __('Views', 'kboard')?></td>
</tr>
</thead>
<tbody>
<?php while($content = $list->hasNextNotice()):?>
<tr class="kboard-list-notice<?php if($content->uid == kboard_uid()):?> kboard-list-selected<?php endif?>">
<td class="kboard-list-title">
<a href="<?php echo $url->getDocumentURLWithUID($content->uid)?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">New</span><?php endif?>
<td class="kboard-list-title">
<a href="<?php echo $url->getDocumentURLWithUID($content->uid)?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">New</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php echo $content->title?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo $content->getUserDisplay()?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo date('Y-m-d', strtotime($content->date))?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo $content->getUserDisplay()?></td>
<td class="kboard-list-date"><?php echo date('Y-m-d', strtotime($content->date))?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php endwhile?>
<?php while($content = $list->hasNext()):?>
<tr class="<?php if($content->uid == kboard_uid()):?>kboard-list-selected<?php endif?>">
<td class="kboard-list-uid"><?php echo $list->index()?></td>
<td class="kboard-list-title">
<a href="<?php echo $url->getDocumentURLWithUID($content->uid)?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">New</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php echo $content->title?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo $content->getUserDisplay()?></span>
<span class="contents-separator kboard-nation">|</span>
<span class="contents-item kboard-nation"><?php echo get_user_meta($content->member_uid, 'user_nation100', true)?></span>
<span class="contents-separator kboard-experience">|</span>
<span class="contents-item kboard-experience"><?php echo get_user_meta($content->member_uid, 'user_experience', true)?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo date('Y-m-d', strtotime($content->date))?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo $content->getUserDisplay()?></td>
<td class="kboard-list-nation">
<?php echo get_user_meta($content->member_uid, 'user_nation100', true)?>
</td>
<td class="kboard-list-experience">
<?php echo get_user_meta($content->member_uid, 'user_experience', true)?>
</td>
<td class="kboard-list-date"><?php echo date('Y-m-d', strtotime($content->date))?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php $boardBuilder->builderReply($content->uid)?>
<?php endwhile?>
</tbody>
</table>
</div>
<!-- 리스트 끝 -->
<!-- 페이징 시작 -->
<div class="kboard-pagination">
<ul class="kboard-pagination-pages">
<?php echo kboard_pagination($list->page, $list->total, $list->rpp)?>
</ul>
</div>
<!-- 페이징 끝 -->
<!-- 검색폼 시작 -->
<div class="kboard-search">
<form id="kboard-search-form-<?php echo $board->id?>" method="get" action="<?php echo $url->toString()?>">
<?php echo $url->set('pageid', '1')->set('target', '')->set('keyword', '')->set('mod', 'list')->toInput()?>
<select name="target">
<option value=""><?php echo __('All', 'kboard')?></option>
<option value="title"<?php if(kboard_target() == 'title'):?> selected<?php endif?>><?php echo __('Title', 'kboard')?></option>
<option value="content"<?php if(kboard_target() == 'content'):?> selected<?php endif?>><?php echo __('Content', 'kboard')?></option>
<option value="member_display"<?php if(kboard_target() == 'member_display'):?> selected<?php endif?>><?php echo __('Author', 'kboard')?></option>
</select>
<input type="text" name="keyword" value="<?php echo esc_attr(kboard_keyword())?>">
<button type="submit" class="kboard-default-button-small"><?php echo __('Search', 'kboard')?></button>
</form>
</div>
<!-- 검색폼 끝 -->
<?php if($board->contribution()):?>
<div class="kboard-default-poweredby">
<a href="https://www.cosmosfarm.com/products/kboard" onclick="window.open(this.href);return false;" title="<?php echo __('KBoard is the best community software available for WordPress', 'kboard')?>">Powered by KBoard</a>
</div>
<?php endif?>
</div>
간단하게 아래 코드를 만들어봤습니다.
if문으로 value값을 체크해서 텍스트를 반환할 수 있습니다.
function get_teamdxc_user_nation100($user_id){
$user_nation100 = get_user_meta($user_id, 'user_nation100', true);
if($user_nation100 == '0'){
return '한국';
}
else if($user_nation100 == '1'){
return '미국';
}
else if($user_nation100 == '2'){
return '기타';
}
return '';
}
고맙습니다.