• Resolved abenes

    (@abenes)


    I’m developing a plugin that automatically approves comments posted by users who meet certain conditions of their accounts.

    My question is whether should I assign special role to eligible users and approve comments by whoever has that role, or whether should I create custom column in wp_users table, save the eligibility information as a boolean value there and ask the database for this information every time any user posts a comment. I’m concerned that some WordPress update could rebuild database tables and remove the changes my plugin will have made to the database.

    This plugin can potentially be run on WordPress instances with hundreds of users, so I need a solution that will last. Backing up the database before every update, recovering the data from it to newly formatted database and rewriting the plugin to work with new database format is out of the question.

    Kind thanks for any help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Please never alter the structure of the default WP DB tables! Doing so will cause serious problems during updates. If you want to associate custom data with users, either use usermeta or add your own custom table that relates to users by their ID. You can alter columns in the admin list tables we see in the back end, but never alter the WP DB tables themselves.

    I think managing eligibility by role is a reasonable solution. IMO, even better would be to manage by a custom capability. A capability can then be assigned to any role or any individual user regardless of role. You can then verify that someone can post auto-approved comments with something like current_user_can('auto_comment') or what ever you want to call the capability.

    Thread Starter abenes

    (@abenes)

    Thanks for Your advice, I’ll keep it in mind whilst further plugin development.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Assign user role or read from custom wp_users table column’ is closed to new replies.