Support Forum ยป User Profile

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: โœ…New Posts are not added to table #11760
    toddmckeetoddmckee
    Participant

    Anh,

    I don't know the specific reason behind the behavior, but I have noticed a couple of things that might lead to the answer. If you remove the custom table option and post everything to the postmeta table, empty values are pushed as empty serialized data "a:0{}". In the custom table, no data is pushed for empty fields. I had a similar issue with advanced select fields in the past. I had to set a default value of "a:0{}" in the database for these fields.

    So my code at to check is:

    add_action('rwmb_physicians_before_save_post', function( $post_id )
    {
      // Create full name to store in 'physician_full_name' field
      $first_name = $_POST['physician_first_name'];
      $middle_name = $_POST['physician_middle_name'];
      $last_name = $_POST['physician_last_name'];
    
      $full_name = $last_name . ' ' . $first_name . ' ' . $middle_name;
    
      $_POST['physician_full_name'] = $full_name;
    
      // Get the ID of the post
      $pid = get_the_ID();
    
      global $wpdb;
      $table_name  = $wpdb->prefix."uams_physicians";
    
      // Check if the ID exists in the custom table
      $ID = $wpdb->get_var("SELECT ID FROM $table_name WHERE ID = '$pid'");
      // If the ID doesn't exist, insert a new row with the ID
      if (!$ID) {
         // Insert
         $wpdb->insert( $table_name, array(
           "ID" => get_the_ID()
          ),
          array( '%s' )
        );
      }
    
    } );

    physicians is the metabox set.

    in reply to: โœ…New Posts are not added to table #11739
    toddmckeetoddmckee
    Participant

    I've come up with a workaround / solution.

    I'm using a before_save_post action to check if the ID exists in the custom table. If not, I insert a row with the ID. This ensures the meta boxes can save normally.

    I can post the code if anyone else is interested or having a similar issue.

    Thanks,
    -Todd

    in reply to: โœ…New Posts are not added to table #11731
    toddmckeetoddmckee
    Participant

    I found part of the issue, but I don't know how to proceed. The issue is the groups. If I disable them, I can save the data. Is there a suggestion on how to handle the groups with a custom table.

    Thanks,
    -Todd

    in reply to: Empty advanced fields in custom table #7917
    toddmckeetoddmckee
    Participant

    FYI - My workaround to make the fields varchar(255) with a default of a:0{}.

    This is not a perfect situation, but it should work with the type of data I'm handling.

    in reply to: Issue with complex form and columns #7893
    toddmckeetoddmckee
    Participant

    Do we have an estimate as to when this will be updated?

    Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)