Sandeep Varma
Sandeep Varma

Reputation: 322

Store and retrieve checkbox state in wordpress using database

I am developing a WordPress plugin. I want to create checkbox as per user roles in WordPress and disable some features for checked user roles. Is there any way to store checkbox state in the database and retrieve it from the database.

Upvotes: 0

Views: 551

Answers (2)

Sjors
Sjors

Reputation: 1215

You can use the function update_option() to save values to the database, then get the saved value with get_option().

Use true when checked, false when not checked :)

Upvotes: 1

Bart
Bart

Reputation: 515

Give this Plugin a try: https://wordpress.org/plugins/members/

it let's you manage role and the capabilities (features) and even create new roles. Also it provides you a good way to restrict content access.

Upvotes: 0

Related Questions