The $havemeta variable isn’t defined inside your shopping_location_text() function, so it isn’t available for use there.
For a quick fix (or for testing/toying) you can move your code inside the function, like this:
add_action( 'woocommerce_before_main_content', 'shopping_location_text', 10 );
function shopping_location_text() {
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);
if( is_shop() ) {
print '<p class="shopping-location-text">YOUR ARE CURRENTLY SHOPPING IN <span style="FONT-WEIGHT: 700;COLOR: #fa4516;">' . $havemeta . '</span></p>';
}
}
Related Posts:
- Get meta_query value by user meta array
- How to make an meta_query optional?
- Adding number to date not working [closed]
- Is it possible to retrieve all posts with a certain value for metadata?
- WP_Query: getting posts where custom field exists
- Usermeta data unserialize, extract and display in table in WordPress
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- WP_query meta_query slow with OR and DATES
- How to use something like meta_query but for fields?
- Too many if’s and else if’s ?? – Must be better way [closed]
- Problem with custom user fields default value and retrieval
- How to update custom fields using the wp_insert_post() function?
- Display all values of custom a field created with ACF on a page
- Adding custom input for data attribute in insert media modal
- If Custom Field is empty don’t display div
- Update WordPress Custom Field with AJAX on cached page
- Sortable admin column for one meta key with three possible meta values
- how to increase custom post value by one most efficiently?
- Passing the custom field values in the wp_get_current_user array function
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- How to check if a meta value has already been assigned to any user?
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- Firing schema via code in functions.php doesn’t work
- Update user profile information from functions.php
- auto-populating custom nav with all items from custom post type
- Trying to retrieve post meta
- a:0:{} is replaced into database as s:6:”a:0:{}”;
- How to combine 2 php functions into one function with a custom field
- Advanced Custom Fields – display label and value only if value entered
- Saving zero in meta box
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Why does this update_post_meta function not delete the custom field itself?
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- How to update and save user metadata on page visits?
- If Array Values Match Another Array’s Values, Then
- Shortcode for Listing Users from Meta Value?
- if custom field doesn’t exist, use post thumbnail instead, as image background
- How to store multiple custom meta box
- How to hide posts of a specific custom category in WordPress?
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- Passing an array into WP_Query as a variable
- WordPress meta_query >= &
- Handling repeater data
- How to add data to a custom field at the wp_users table?
- Define category ID using get_post_meta
- Including Custom fields within the_content
- Comparing Dates from custom field
- Adding custom url to readmore link using get_permalink()
- Display movies that apear this day next
- Add “alt” Attribute to GD Star Rating Tags
- custom header text
- Using a string from a custom field within a link
- Make separate text boxes for separate WordPress Custom Fields
- Add custom fields from different posts
- Delete images from media library when user deletes an image from ACF Gallery
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Order category posts by last word of custom field
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- Display custom field value in woocommerce variable product via jQurey
- Block error message in foreach loop when looping through ACF field
- User meta needed in query is serialized – how to unserialize safely?
- Include User ID in iFrame URL
- WP custom posts: filter results to custom taxonomy tag that corresponds to user meta field
- How to save multiple values with same meta_key, each value linked to another tag id
- Change user metadata on registration (show_admin_bar_front = false)
- Where does php code to load data go?
- Store data from JavaScript object to custom table in user account
- How to change the value of a variable using input field?
- Get user by meta data key and velue
- Where do I implement this display of User Meta Data, and how to put it in a table?
- Update an additional user meta field with a string
- Meta query not showing result properly
- Add another role to a user when they click a button?
- Right way to display the_author_meta fields?
- Adding user meta to post meta wp_insert_post() not working
- How to display custom field from a gallery thumbnail?
- How can get all users by current user meta (array)?
- Getting a value from a custom field from a page that shares a parent with the current page
- Efficient way of querying for a “fallback” post?
- If custom field doesn’t exist, or exists and it’s true show title?
- Let users register weight each day and save it in DB
- Outputting a custom field in PHP
- Sorting Meta Fields?
- Custom fields randomly stop working
- Display selected parts from selected pages on the frontpage?
- Where can I find the code for the menu page meta boxes?
- How to echo a different field if another field is empty?
- PHP Puzzle: Unique Styles with PHP loop
- Metadata on the WP_Post object
- Appending an ACF custom field to the page title
- WP query with variables gives no result for specific user
- Displaying custom meta box value in a custom post page
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- fetch from an external api call and display results in page
- Cannot Access ACF Field Values via my Plugin
- hide “Open in New Tab” checkbox in link field
- Custom rest fields not loaded in rest api cpt response