-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User profile fields are pre populated with current user data #427
Comments
I've managed to solve this problem by updating the IF statement at line 228 in CMB2_Field.php with the following: // If no override, get value normally
if ( 'cmb2_field_no_override_val' === $data ) {
switch (true) {
case ($a['type'] === 'options-page'):
$data = cmb2_options( $a['id'] )->get( $a['field_id'] );
break;
case ($a['type'] === 'user' && get_current_screen()->action === 'add'):
$data = cmb2_options( $a['id'] )->get( $a['field_id'] );
break;
default:
$data = get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) );
}
} |
This has been addressed in the trunk branch, thank you for reporting! Please please please don't modify CMB2 core as there may be other plugins depending on your copy of CMB2 (because of the way CMB2 loading works) and while your edits may work for your use-case, it's alway possible that they could break somebody else's. |
Thank you for the quick reply! The only reason I posted my solution is because I need a temporary fix until a new version of CMB2 is released and I thought this might help somebody else, but you are right. Thank you again for the great work you do! |
Understood. Did you happen to test trunk? It should be good (it worked for me), but want to verify. |
Yes, it worked as expected. |
Whenever I am adding a new user, the custom fields come pre populated with the current user's data. I am using CMB2 2.1.0 with WordPress 2.4.2
Tested field types: text and file (with and without default values).
The text was updated successfully, but these errors were encountered: