Support

Account

Home Forums Backend Issues (wp-admin) update_field() with field type User Reply To: update_field() with field type User

  • 
    // ...................
      } elseif ($product_id == 1126) {
        $e_post = get_page_by_title( $title );
        $epost_id = $e_post->ID;
        $member = wp_get_current_user();
        $newmember = $member->ID;
        
        $members = get_field('comp_members', $epost_id, false);
        if (!is_array($members)) {
          $members = array();
        }
        $members[] = $newmember;
        
        update_field( 'comp_members', $newmember, $epost_id);
        echo "New Member, $newmember , added to $title.";
    
    } // End of new member