WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm tweaking a plugin and I'd like to have an option value different for each backoffice user.

Currently the options are defined using the add_settings_field method that is performed in the admin_init hookup.

My question is, could I register a new set of settings by prefixing my settings using the current user ID?

Such a way, if valid, could help to solve other problems, such:

share|improve this question
up vote 3 down vote accepted

Yes, you can and it's easier using a Class. In the admin_init hook (where the Settings API is being registered and defined) set a class property based on the user ID:

$this->prefix = 'uid_' . get_current_user_id() . '_';

Then, in the rest of the code, refer to your option name as $this->prefix . 'option_name'.

The result in the table wp_options will be uid_1_option_name, uid_2_option_name, etc. And each user will have its own settings.

A Gist with a working example.

share|improve this answer

Your Answer


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.