• Resolved showtek

    (@showtek)


    Hello,

    I am having a pretty hard problem to solve since I am not advanced enough in PHP and woocommerce function understanding. Basically, what I am trying to do is to create a properly functioning custom My Account page with 3 field forms, however, the main struggle is figuring out how to save the fields, and update the metadata.

      1. I have made a new end-point called “Instagram credentials”
      2. Added the Account menu item so it could be pressed and redirected to Instagram credentials.
      3. Created the function with fields with PHP & HTML language as per provided templates.
      4. I added a button at the end that does nothing because I know nothing about saving.
      5. Added check & validation function
      6. Added save function.

    Problem:

      At step 4. I have a problem understanding how to request an action to actually save the data that is input. I assume the button should request and call the step 5 & 6 but no documentation expresses it or I simply lack the skills.

    Here is the code posted in GitHub to conserve the syntax for better reading: https://github.com/showtek320/my-account/blob/master/Instagram-credentials

    Any help would greatly be appreciated!

    • This topic was modified 5 years, 4 months ago by showtek.
    • This topic was modified 5 years, 4 months ago by showtek.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Remi Corson

    (@corsonr)

    Automattic Happiness Engineer

    Hi there,

    Saving fields from the my-account page is explained here in case you choose to use the default page, instead of creating a new endpoint:

    https://iconicwp.com/blog/the-ultimate-guide-to-adding-custom-woocommerce-user-account-fields/

    That’s what I could do.

    However, if you want to stick to your custom endpoint, I guess you could try with save_account_details instead of woocommerce_save_account_details/

    Thread Starter showtek

    (@showtek)

    Thank you for your answer Remi, however, the main problem is that I do not know how to trigger the function, with a button. I do not understand how the button itself is created that will make the function trigger

    Iamhere

    (@iamhere)

    Hi @showtek did you ever find an answer to this – I have the same issue – a custom woocommerce endpoint page, with some custom form fields, but hooking into the save_account_details function doesn’t work because then, the form is looking for the fields related to that form (first name, last name, email etc) which are not there.

    Thread Starter showtek

    (@showtek)

    Hey @iamhere, unfortunately, nobody really helped to resolve this problem and I had to go to freelance a programmer to do it for me. I cannot really explain what did he do it but in short, it was similar to the code I posted above but with a lot of additions regarding encoding and decoding & submission with html based request. I can try to share the code privately.

    Remi Corson

    (@corsonr)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘My account custom fields w/ save button not working’ is closed to new replies.