Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @angeloarlotta

    Unfortunately, this requires customization with UM hooks to add custom fields and custom tabs in the Account form. You can try checking the tutorial at the link.

    Regards,

    Thread Starter angeloarlotta

    (@angeloarlotta)

    Hi @champsupertramp this tutorial is about adding a new tab.
    The question in this case is about the ability to add and save custom fields into the account tab so I found this:
    https://gist.github.com/champsupertramp/c1f6d83406e9e0425e9e98aaa36fed7d

    The fields were added but users can’t save it.

    Why an important feature like this is not included even in a dedicated addon on a famous plugin like Ultimate Member?

    Thanks,
    Angelo

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @angeloarlotta

    Please feel free to submit a feature request on our Public Github repository:
    https://github.com/ultimatemember/ultimatemember/issues

    IF more people want this, we’ll work on it in the next couple of weeks. We don’t put too many features as it will make it more complicated. We have UM hooks to extend UM features/functionality to achieve client requirements and for many usages and different instances.

    Regards,

    • This reply was modified 4 years, 11 months ago by Champ Camba.
    • This reply was modified 4 years, 11 months ago by Champ Camba.
    Thread Starter angeloarlotta

    (@angeloarlotta)

    Hi @champsupertramp,
    the Github page I shared is active since 2015 so I think this is a useful feature for anyone.

    Anyway, can you please share an updated code working also when saving fields?

    Thank you very much for helping!

    Thread Starter angeloarlotta

    (@angeloarlotta)

    This is the code I’m using:

    
    add_action('um_after_account_general', 'showUMExtraFields', 100);
    
    global $ultimatemember;
    $user_id = um_user('ID');
    
    function showUMExtraFields() {
      $id = um_user('ID');
      $output = '';
      $names = array('professioni');
    
      $fields = array(); 
      foreach( $names as $name )
        $fields[ $name ] = UM()->builtin()->get_specific_field( $name );
      $fields = apply_filters('um_account_secure_fields', $fields, $id);
      foreach( $fields as $key => $data )
        $output .= UM()->fields()->edit_field( $key, $data );
    
      echo $output;
    }
    
    add_action('um_account_pre_update_profile', 'getUMFormData', 100);
    
    function getUMFormData(){
      $id = um_user('ID');
        $names = array('professioni');
    
      foreach( $names as $name )
        update_user_meta( $id, $name, $_POST[$name] );
    }
    

    Please, what I’m missing here? I read thousand messages here: https://gist.github.com/champsupertramp/c1f6d83406e9e0425e9e98aaa36fed7d

    …but seems there’s some incompatibility with the new UM version so the fields doesn’t save values.

    Thanks.
    Angelo

    Thread Starter angeloarlotta

    (@angeloarlotta)

    After deeper testing and other users notices, seems that the problem is I’m trying to save a dropdown field.
    I tried saving a simple custom text field and it works, but the dropdown fields are not being saved.

    Please @champsupertramp how to solve?

    Thanks!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @angeloarlotta

    What’s the final code you’re using? Could you please share so I can review them?

    Regards,

    Thread Starter angeloarlotta

    (@angeloarlotta)

    Hi @champsupertramp thank you for your reply I just found a solution and I hope this is the right procedure in this case.

    I followed this article about the use of choises callback feature:
    https://docs.ultimatemember.com/article/1486-how-to-use-choices-callback

    So, if it could be useful for other users, I declared the fields in this code:

    
    function custom_dropdown_items() {
    	$customfieldname = array( "Option 1" => "Option 1", "Option 2" => "Option 2", "Option 3" => "Option 3" );
    		return $customfieldname;
        }
    

    Then I went into UM > forms and edited my custom dropdown field, adding the function name “custom_dropdown_items” into the Choices Callback field.

    Hope this is the correct solution to correctly store infos into the database.

    Thank you,
    Angelo

    • This reply was modified 4 years, 11 months ago by angeloarlotta.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @angeloarlotta

    Thanks for letting us know how you’ve resolved the issue.

    Regards,

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Custom fields into account tab’ is closed to new replies.