Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to modify a plugin and in which i require to update a value in wp_options which has multiple values .

My option_name is ws_mem_options

and the

option_value has values such as in format

s:20:"pro_sp_email_subject";s:36:"Thank You! (instructions for access)";s:20:"mem_email_message";s:309:"Thanks %%first_name%%!

%%item_name%%

Transaction ID: %%txn_id%%
Charges today: $%%amount%%

Your order can be retrieved here:
%%sp_access_url%%
( link expires in %%sp_access_exp%% )

If you have any trouble, please feel free to contact us.

Best Regards,
Don't Just Watch TV, Participate!";s:120:"mem_coupon_codes";s:66:"CHRISTMAS-25|25%|01/01/2021
100%OFF|100%
SAVE-10|10%
dumpme|10%";s:15:"mem_default_tax";s:4:"0.0%";s:13:"mem_tax_rates";

how can i add more values to

s:120:"mem_coupon_codes";s:66:"wow-25|25%|01/01/2021
    100%OFF|100%
    now-10|10%
    dumpme|10%";
share|improve this question
    
Is this value in full? Is it taken from DB directly or some function's output? It looks like multiple serialized values glued together. –  Rarst Dec 1 '13 at 14:10

2 Answers 2

If you have access to run SQL queries, you can select the option_value you want to change and update it with new option_value by running an SQL query.

share|improve this answer

What you are looking at is serialized data-- possibly multiple bits of serialized data as @Rarst noted. The Options API will serialize and unserialize automatically so all you need to do is:

$data = get_option('optionkey');
// $data will be unserialized into whatever data type it was originally, object, array, etc
// manipulate your data with ordinary PHP object and array techniques
update_option('optionkey',$data);

Reference

http://codex.wordpress.org/Function_Reference/get_option
http://codex.wordpress.org/Function_Reference/update_option

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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