这一次我简直疯了,我一辈子都搞不明白为什么我没有收到字符串内容。
var\\u dump完美地输出了正确的结果,但是$havemeta的内容是空的。真的需要一些投入。
add_action( \'woocommerce_before_main_content\', \'shopping_location_text\', 10 );
global $current_user;
get_currentuserinfo(); // wordpress global variable to fetch logged in user info
$userID = $current_user->ID; // logged in user\'s ID
$havemeta = get_user_meta($userID, \'location_select\', true); // stores the value of logged in user\'s meta data for \'location_select\'.
var_dump($havemeta);
function shopping_location_text() {
if( is_shop() ) {
print \'<p class="shopping-location-text">YOUR ARE CURRENTLY SHOPPING IN <span style="FONT-WEIGHT: 700;COLOR: #fa4516;">\' . $havemeta . \'</span></p>\';
}
}