Support

Account

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.