• I’m trying to customize the registration process on my WordPress site to capture additional user information?such as phone number. I have Added Custom register fields in the Learn-press setting profile section and it shows correctly in the user profile page.

    I tried to update the filed during my custom registration process with update user meta function but it doesn’t work

    Assuming [7708364] is my custom Field ID

    update_user_meta( $user_id, ‘_lp_custom_register[7708364]’, $value);

    Appreciate your advice

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support brianvu-tp

    (@briantp)

    Hi anamostafa,

    Thank you for reaching out!

    If I understand correctly, you have customized a new registration form and want to pass the data entered in the Custom Register Fields from LearnPress settings to display it at your customized location or store it as user meta. Is that correct?

    If not, could you please clarify your requirements so I can provide a more accurate solution?

    Looking forward to your reply!

    Best regards,
    Brianvu-tp

    Thread Starter anamostafa

    (@anamostafa)

    Yes exactly, I added a new Custom Register Fields?from LearnPress settings called “phone number” and it has appeared in users profile in wp admin

    And I am using a custom registration form and force user to fill in his phone so want to store the number as user meta, that’s why I used update_user_meta function

    Plugin Support brianvu-tp

    (@briantp)

    Hi anamostafa,

    Thank you for clarifying!

    We’ve understood your use case. However, the method you’re using to retrieve and update the custom registration field data is not correct. you cannot directly update the custom field data using update_user_meta with the field ID like in your example. LearnPress stores all custom registration fields in a single meta key called _lp_custom_register, which is an array.

    Instead, LearnPress stores all custom registration fields together under the _lp_custom_register meta key. To handle this properly, you need to retrieve the entire _lp_custom_register array and update the specific field.

    You can check how LearnPress manages custom registration fields in the following functions:

    1. Form Creation:
      The learnpress_create_new_customer function handles creating new user data, including custom fields.
      Path:
      wp-content/plugins/learnpress/inc/class-lp-forms-handler.php
    2. Custom Field Update:
      The lp_user_custom_register_fields function processes and updates custom registration fields.
      Path:
      wp-content/plugins/learnpress/inc/user/lp-user-functions.php

    To properly update the custom field, retrieve the entire _lp_custom_register array, then update the specific field and save it back.

    Let me know if you need further assistance with this!

    Best regards,
    Brianvu-tp

    Thread Starter anamostafa

    (@anamostafa)

    Hi Brianuv,

    I simply tried with the following with my function but I guess I missed something , considering that the user is just created and all “_lp_custom_register” array is still empty

    // I Get the existing ‘_lp_custom_register’ meta value array

    $register_fields_array = get_user_meta( $user_id, '_lp_custom_register', true );


    //Then I modified the array key with my custom text

    $register_fields_array [7708364] = 'custom text';

    // Finally I update the ‘_lp_custom_register’ meta with the modified array

    update_user_meta( $user_id, '_lp_custom_register', $register_fields_array );


    However, the field with key [7708364] is only updated with first letter “c”

    I really appreciate your help

    • This reply was modified 2 months, 2 weeks ago by anamostafa.
    Plugin Support brianvu-tp

    (@briantp)

    Hi anamostafa,

    Thank you for your detailed explanation!

    Based on your description, it seems this issue may be more complex and potentially related to how LearnPress processes and saves the custom registration fields. To properly diagnose the root cause and assist you further, we would need to investigate this more thoroughly.

    To proceed, we recommend creating a free support ticket in our official forum. Please include the details you’ve provided here and use a subject like “anamostafa Custom register field ID”.

    You can create your ticket by visiting our forum and clicking on the Support section.

    Once your ticket is created, our development team will review the issue in detail and provide a precise solution.

    Thank you for your understanding, and we appreciate your patience while we work on resolving this!

    Best regards,
    Brianvu-tp

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.