• If I am not mistaken, the settings api only storing one single data array in wp_options table . You can only change the field data in the section array.

    But what if I need to add a dynamic data in the same section array?

    For example:
    Let say I got multiple users in my site, and I need to set their membership expired data based on each user roles by a plugin.
    In the plugin, I would like to store each of the roles with the expiry date by using settings api. And it would be:

    Subscriber => 30 days after registration
    Contributor => 60 days after registration
    Author => 90 days after registration
    Editor => 120 days after registration
    …etc
    each role will be store in single array. and all these array will be store in single row in wp_options table like this:

    array(
    'Subscriber' = array(
            'date'=> '30',
             ),
    'Contributor' = array(
            'cpt'=> '60',
        ),.....etc
    )

    Also I would like to edit/delete/add each of the role expiry date any time I want. I might have new custom role in the future, so it is essential the plugin able to add new rule for new role.

    What I found on goolge are only tutorial on how to store the data in single array, but I did see some plugin done this, but just couldn’t understand how they done it with my current of programming level.

    I don’t want to create another custom table,since the data that I want to store is not so much. The settings api seem fit my need in this situation.

    Any guides or advice will be appreciated.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to save multiple array in Settings Api single section’ is closed to new replies.