You’re running the query twice and passing the result of the first query to the second query. Give this a try. You might also consider using the update function from wpdb instead of running an arbitrary query because it doesn’t look like you’re doing any data sanitization or nonce checks. If you do want to query, you should use prepare.
function update_company_profile($post_ID) {
global $wpdb;
if ($parent_id = wp_is_post_revision( $post_id )) $post_ID = $parent_id;
$address_1 = get_post_meta($post_ID, 'address_1', true);
$address_2 = get_post_meta($post_ID, 'address_2', true);
$sql = $wpdb->prepare("UPDATE wp_company_profiles SET
address_1 = '%s',
address_2 = '%s',
WHERE pid = %d", $address_1, $address_2, $post_ID);
$wpdb->query($sql);
}
add_action('save_post', 'update_company_profile');
Related Posts:
- update_post_meta and update_field ony working when saving the post
- Update post meta value as date difference between two fields
- ACF (Advanced Custom Fields) not updating post or postmeta values
- Help using acf/save_post hook to connect to Untappd API and update_field [closed]
- How to import CSV into Custom Post Type custom fields?
- ACF – get fields from group
- How to get “Additional CSS Class” for ACF Gutenberg block
- Advanced Custom Fields select field : How to echo the label, not the value? [closed]
- ACF: get_field() returning false [closed]
- Adding custom fields to the header.php
- How to get_terms() only of terms matching an ACF meta value?
- Query between dates using Date Picker fields
- Advanced custom field – gallery – display one random image
- Showing an ACF field in admin posts dashboard
- Google Places API With ACF [closed]
- Check for the existence of custom field
- ACF Repeater Field, need IF statement for if sub field has content
- Can not create fields in ACF with code
- Advanced Custom Fields – Check if multiple get_fields exist?
- ACF – Custom fields have dissappeared [closed]
- Error in Validate Field with ACF plugin in WordPress
- disable (read only) a field if within a custom post type name
- How to change the page title from functions.php
- Acf Pro repeater field returns null [closed]
- Faking the “onSave” event
- Insert Commas into ACF number field
- How I can check if get_theme_mod is in header or a template part
- Using pre_get_posts for meta value of LIKE comparison on ACF repeater sub field
- WP Rest endpoint with custom post type and ACF Fields
- Advanced custom fields: Customise date picker’s start date (need to choose year 1500 onwards) [closed]
- ACF Advanced Custom Fields | Help me grab the fields on my WooCommerce homepage [closed]
- My get_terms not working for custom fields
- How to share repeated fields across multiple pages?
- Remove headings option from Wysiwyg editor from ACF in a certain custom post type
- How to break a date from ACF?
- get all posts in custom post type by ACF field value
- Remove YoastSEO meta description from output/source [closed]
- Advanced Custom Fields changes get stuck in cache
- WordPress Date with ACF
- html element to separate php variable strings – ACF datepicker
- Get image data from advanced custom field [closed]
- Check for image with same filename but different extension
- Advanced Custom Fields if else issue
- If/Else Statement for Advanced Custom Fields
- How to get both image attachment ID and url
- Search and replace not working for ACF Images
- how make file upload field through custom field
- How Do I Use a ACF Custom Field To Add A Slider ID?
- Advanced Custom Fields oembed only outputs YouTube URL
- Update post meta within save_post action
- Hidden field in acf
- Importing ACF code in other page templates
- ACF Content with WPML not saving [closed]
- How do I ensure the social icons appear on all pages? [closed]
- Order get_terms by multiple meta_values
- Strip comma from last element in concatenated JSON string
- How can you query posts by advance custom field when the value is a serialized array? [closed]
- Check for duplicate custom field value before running wp_insert_post
- Query by radio button ACF
- Adding new parent item to admin bar
- Perform function on publish AND save (not just save)
- Display category multi-select with Advanced Custom Felds
- Advanced Custom Fields Plugin: how to use a checkbox to allow a post to show up in desired “zone”?
- ACF: Grid based on field value
- Advanced Custom Field Textarea not Showing (ListingPro Theme)
- Fill up advanced custom field of a custom post type via API REST POST
- Two problems that are likely related to AJAX
- ACF – Eliminate unnecessary data and print
- Is there any way to bulk search-replace URLs that exist within ACF’s “Link” field type (serialized)?
- Get values from an advanced custom field
- Edit (advanced) customs fields on page template
- ACF Posts in Theme Options only returning when logged in? Bug?
- ACF – Adding PHP into Slick Slider Breaks the Slider
- Advanced Custom Fields frontend form submission
- Display of Custom Fields based on conditional if/and according to category/tag choice
- Comparing two dates (ACF and current time)
- Save_post acf data not updating category of post type
- Advanced Custom Fields Gallery and Flex Slider [reformuled]
- Advanced Custom Fields oEmbed video width and height
- Display ACF field(s) from widget in FE
- Convert number to date format within an array
- ACF not updating value correctly
- ACF Repeater and Sort
- Advanced Custom Fields, DatePicker – Check if Set
- How to access advance custom fields with post type in a for each loop
- Pin to Top Functionality using orderby custom field then event date
- Acf Pro repeater field returns null when call inside foreach
- Relationship field search not retriving posts in admin
- advanced custom fields plugin last input field in new posts
- WordPress loop based on url sting
- Display “Today” Instead of Date for Pubslished Posts
- Updating custom fields with data from the database
- Advanced Custom Fields repeter field expiration
- Getting “Invalid argument supplied for foreach()” Warning
- WordPress/Timber/Twig – Trying to output checkbox values [closed]
- How to use WordPress to embed a SoundCloud download link?
- upgrading ACF (advanced custom fields) on an old site [closed]
- Generate the post title from ACF fields
- show only first element from a type with acf
- ACF – if field has value within Field Group conditional statement [closed]