0

Is this possible? I want to use Gravity Forms or another hook to somehow write to the END of a user_meta field - not overwrite it.

For example...

Before:

$purchase_history = get_the_author_meta('purchase_history', $user->ID);
echo $purchase_history; ('Concert in the Park 01/12/2004')

After:

echo $purchase_history; ('Concert in the Park 01/12/2004', 'Pancake Breakfast 05/15/2005')

Any ideas? Thanks.

1 Answer 1

2

Use get_user_meta():

$original = get_user_meta( 
    $user->ID, 
    'purchase_history', 
    TRUE 
);

echo $original . ' Pancake Breakfast 05/15/2005';

To update the value use update_user_meta():

update_user_meta( 
    $user->ID,  
    'purchase_history',   
    $original . 'Pancake Breakfast 05/15/2005' 
);
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.