User Meta Value not echoing despite Var_Dump Showing correct string

I am going absolutely insane with this one, I cannot for the life of me figure out why I am not receiving the string content.

var_dump is outputting the correct result perfectly, yet the content for $havemeta is empty. Really need some input.

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>’;
}
}

Read more here:: User Meta Value not echoing despite Var_Dump Showing correct string

Leave a Reply

Your email address will not be published. Required fields are marked *