Support » Plugin: Ultimate Member - User Profile, Registration & Membership Plugin » What happened to $_SESSION[‘um_account_fields’]

  • Resolved dwlorimer

    (@dwlorimer)


    I could not find this change in the changelog.

    In version 1.3.78, um-filters-account.php had this code:

    	add_filter('um_account_secure_fields','um_account_secure_fields', 10, 2);
    	function um_account_secure_fields( $fields, $tab_key ){
    		//print_R($fields);
    		//print_R($tab_key);
    
    		$_SESSION['um_account_fields'][ $tab_key ] = $fields; 
    
    		update_user_meta( um_user('ID'), 'um_account_secure_fields', $_SESSION['um_account_fields'] );
    		
    		return $fields;
    	}

    Somewhere along the line to version 1.3.88, this code was completely changed.

    I was using this code example to add Advanced Custom Fields to my Ultimate Member Profile tab:
    https://gist.github.com/champsupertramp/c1f6d83406e9e0425e9e98aaa36fed7d

    It relied on the code mentioned above, that has since been changed. Thus, the field still displays but does not save, because update_user_meta is no longer called on $_SESSION[‘um_account_fields’]. What behavior replaced this function?

    I know that you do not provide support for custom code, which is ok. But I would like to be informed of how the plugin now handles saving fields, as it is a significant change to the plugin, and I could not find it addressed in the changelog. If it is in the changelog, please direct me to the location.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • I was able to find and solve this change.

    Please see my comments at this link:
    https://gist.github.com/champsupertramp/c1f6d83406e9e0425e9e98aaa36fed7d

    It appears that UM changed the um_account_secure_fields from wanting the name of the tab, to wanting the id of the user (but the code comments still say $tab_key).

    The change appears to be this:

    global $ultimatemember;
    $id = um_user('ID');


    $fields = apply_filters( 'um_account_secure_fields', $fields, $id );

    Instead of the old:
    apply_filters('um_account_secure_fields', $fields, 'general' );

    Hi dwlorimer,

    thanks for the code – I found it via GitHub and used it to extended the account tabs “general” and “privacy” with custom fields (“general” by a textbox field, “privacy” by a checkbox field).

    So maybe you can help me with my little problem:

    Since several days I can’t save the changes of the checkbox field anymore, the textbox is still doing fine.

    I already tried a conflict test with no results.

    Here’s my code:

    add_action('um_after_account_privacy', 'showExtraFields', 100);
    function showExtraFields()
    {
      global $ultimatemember;
      $id = um_user('ID');
      $output = '';
    
      $names = [ 'terms' ];
    
      $fields = [];
      foreach( $names as $name )
        $fields[ $name ] = $ultimatemember->builtin->get_specific_field( $name );
    
      $fields = apply_filters( 'um_account_secure_fields', $fields, $id );
    
      foreach( $fields as $key => $data )
        $output .= $ultimatemember->fields->edit_field( $key, $data );
    
      echo $output;
    }

    I’m still using UM 1.3.88 free version with WP 4.9.

    Thanks for your help in advance!

    • This reply was modified 2 years, 10 months ago by coxinha.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘What happened to $_SESSION[‘um_account_fields’]’ is closed to new replies.