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:

1 Answer 1


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.

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.