Home › Forums › Front-end Issues › Generating usermeta field with PHP › Reply To: Generating usermeta field with PHP
Ok so here’s what I did, since the group field and the fields are created in the wp_posts table, I just checked the group ID and then proceed to list any field attached to it in a loop and then doing two add_user_meta() for each field :
$get_fields = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'posts WHERE post_parent ="id_of_the_group"');
foreach ( $get_fields as $field ) {
switch ($field->post_excerpt) {
case 'my_acf_field_name' :
add_user_meta($user_id, $field->post_excerpt, $_POST['my_value']);
add_user_meta($user_id, '_'.$field->post_excerpt, $field->post_name);
break;
case '...
I know this is really really dirty coding but sadly this is the best I can do.
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.