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
- Display posts in correct month order using single date custom field
- Firing schema via code in functions.php doesn’t work
- How can I save unique user data on my site? [closed]
- How can I add extra word in permalink when someone click download button?
- Saving and Restoring a Canvas on A Individual User Basis
- Seach custom post type posts only by meta fields?
- How to use thumbnail size of image if I’m only using src to get image
- How to abort saving data in save_extra_profile_fields function WordPress?
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- how to retrieve a value if a checkbox is checked
- Trouble checking if custom woocommerce checkout field is empty or not
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Let Users Choose Post Categories
- Custom query, checking values of multiple meta keys
- Archive post by meta value + 24hours
- Update user profile information from functions.php
- auto-populating custom nav with all items from custom post type
- Add / Update Custom Fields After Select Pictures in Media Window
- conditional logic for front-end custom field edits
- Trying to retrieve post meta
- Automatic Shortcode Creation with Custom Fields [closed]
- Custom field values to taxonomy terms
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Custom Field IF/ELSE PHP
- Which PHP page is the Default Posts Page
- a:0:{} is replaced into database as s:6:”a:0:{}”;
- How to combine 2 php functions into one function with a custom field
- Remove the last X characters of a custom field value
- Advanced Custom Fields – display label and value only if value entered
- get_users meta_query: REGEXP not working for matching new lines
- Grouping posts by a custom meta value
- Saving zero in meta box
- Non-Closing PHP Query in WordPress Loop
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Find a way to retrive data updated through metabox plugin to web page
- Read array in php?
- Why are the details of my todo not saving?
- How to check if a PHP string is different than meta field?
- Can’t save php string to a custom field
- Display custom field on 404 page outside loop
- Why does this update_post_meta function not delete the custom field itself?
- How to show/hide php table rows based on the content of custom fields
- Run str_replace on title and save the output to a custom field
- Countdown to date function?
- Only show image from custom field when present
- how to get serialized post meta
- Hide Heading if ACF Field is empty
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- Custom meta box values are not getting saved for my custom post type
- Getting users with a specific meta data and then querying their posts?
- How to update and save user metadata on page visits?
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- How to show meta value code HTML after x paragraph
- Login redirect. Check user meta and redirect accordingly
- Creating an image from a custom field
- If Array Values Match Another Array’s Values, Then
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Shortcode for Listing Users from Meta Value?
- if custom field doesn’t exist, use post thumbnail instead, as image background
- Getting different user data depending on where I use variable
- WP All Import / Update stock quantity from multiple XML files
- 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]
- Adding Author Box Meta Links with Co-Authors
- Undefined offset: 0-wp-includes/meta.php:488 -Melding
- Passing an array into WP_Query as a variable
- WordPress meta_query >= &
- Get the users that my following users are following
- Handling repeater data
- How to add data to a custom field at the wp_users table?
- Comapare get_user_meta value
- How can get all users by current user meta?
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- How do I remove duplicate users from two merged WP_User_Query objects?
- Concatenate Custom Field Value & HTML Value
- Output custom text field as unordered list
- Conditional featured image with youtube thumbnail
- `update_post_meta` not working anymore
- Order a WP_Query by meta value where the value is an array
- Edit Account – read and write to MySQL
- Unable to render custom field after attempt to generate a list of recent post in page template
- Add a custom class to the body tag using custom fields
- Define category ID using get_post_meta
- Add a counter for mouseovers (custom field)
- Hide a div when a custom field is empty
- Including Custom fields within the_content