目前,我正在开发一个使用Dokan多供应商插件的网站。我在注册表中添加了一个自定义字段
以下代码用于在注册表中添加自定义字段
<p class="form-row form-group form-row-wide">
<label for="tskypeid"><?php _e( \'Skype ID\', \'dokan-lite\' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text form-control" name="tskypeid" id="tskype-id" value="<?php if ( ! empty( $postdata[\'tskypeid\'] ) ) echo esc_attr($postdata[\'tskypeid\']); ?>" required="required" />
</p>
这是用于保存字段数据的代码:
// save skype id after registration
function ms_dokan_on_create_seller( $user_id, $data ) {
if ( $data[\'role\'] != \'seller\' ) {
return;
}
$dokan_settings = array(
\'tskypeid\' => $_POST[\'tskypeid\'],
);
update_user_meta( $user_id, \'dokan_profile_settings\', $dokan_settings );
update_user_meta( $user_id, \'dokan_store_name\', $dokan_settings[\'store_name\'] );
do_action( \'dokan_new_seller_created\', $user_id, $dokan_settings );
}
add_action( \'woocommerce_created_customer\', \'ms_dokan_on_create_seller\', 10, 2);
尝试使用以下代码访问该值:
function wc_vendors_name_loop( $store_id ) {
$user_id = get_current_user_id();
$dokan_profile_settings = get_user_meta( $user_id )
[\'dokan_profile_settings\'];
echo "<pre>";
var_dump( $dokan_profile_settings );
echo "</pre>";
}
add_action( \'wp_footer\', \'wc_vendors_name_loop\' );
此代码输出以下结果:
array(1) {
[0]=>
string(1183)
"a:17:{
s:8:"tskypeid";
s:7:"asdfasd";
s:10:"store_name";
s:17:"asdfas dfasdfasdf";
s:9:"store_ppp";
i:0;s:7:"address";
a:6:{
s:8:"street_1";
s:19:"fasdf asdf asdf sad";
s:8:"street_2";
s:15:"sadf asdf asd f";
s:4:"city";
s:10:"asdf asd f";
s:3:"zip";
s:8:"sad fsad";
s:7:"country";
s:2:"AZ";
s:5:"state";
s:9:"asdfasdf ";
}
s:8:
"location";
s:0:"";
s:12:"find_address";
s:27:"dsfas sadf sadfsadfsadf asf";
s:6:"banner";
i:0;s:5:"phone";
s:9:"345346456";
s:10:"show_email";
s:3:"yes";
s:14:"show_more_ptab";
s:3:"yes";
s:8:"gravatar";
i:0;s:10:"enable_tnc";
s:2:"on";
s:9:"store_tnc";
s:27:"asdf asdf asdfa sdf sadfsdf";
s:18:"profile_completion";
a:6:{
s:5:"phone";
i:10;s:10:"store_name";
i:10;s:7:"address";
i:10;s:9:"next_todo";
s:31:"Add Banner to gain 15% progress";
s:8:"progress";
i:30;s:13:"progress_vals";
a:8:{
s:10:"banner_val";
i:15;s:19:"profile_picture_val";
i:15;s:14:"store_name_val";
i:10;s:10:"social_val";
a:5:{
s:2:"fb";
i:2;s:5:"gplus";
i:2;s:7:"twitter";
i:2;s:7:"youtube";
i:2;s:8:"linkedin";
i:2;
}
s:18:"payment_method_val";
i:15;s:9:"phone_val";
i:10;s:11:"address_val";
i:10;s:7:"map_val";
i:15;
}
}
s:23:"show_min_order_discount";
s:2:"no";
s:28:"setting_minimum_order_amount";
s:0:"";
s:24:"setting_order_percentage";
s:0:"";
}"
}
这里我想访问第5行中的“tskypeid”值,第6行中的值是“asdfasd”
请告诉我如何访问该值。
任何帮助都将不胜感激。
提前谢谢你。