Home › Forums › General Issues › Populating custom Input Field values from custom database values › Reply To: Populating custom Input Field values from custom database values
okay so I got the values to populate using the code below
function populate_phone($field) {
global $wpdb; //use wp database
$field['value'] = 'N/A'; //default value
$current_user_id = get_current_user_id(); //get logged in user's id
$wp_custom_user_info = $wpdb->get_results("
SELECT * FROM custom_table
WHERE wp_user=" . $current_user_id
);
$field['value'] = $wp_custom_user_info[0]->phone_numbers;
return $field;
}
add_filter('acf/load_field/name=phone', 'populate_phone');
My other question still stands: How do I update that value after pressing “Save/Update” button?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.