1

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%";
1
  • 1
    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, 2013 at 14:10

2 Answers 2

3

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

0

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.

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.