# HG changeset patch # User Kim Alvefur # Date 1315774403 -7200 # Node ID 6f2e37d0a1b0a8481fb061b0d9d97badc8b97f66 # Parent 34eb9df9e37f6218c7cbc4320f3c8fb5582b832d mod_auth_wordpress: Allow table prefix to be configured diff -r 34eb9df9e37f -r 6f2e37d0a1b0 mod_auth_wordpress/mod_auth_wordpress.lua --- a/mod_auth_wordpress/mod_auth_wordpress.lua Sun Sep 11 22:05:13 2011 +0200 +++ b/mod_auth_wordpress/mod_auth_wordpress.lua Sun Sep 11 22:53:23 2011 +0200 @@ -13,6 +13,7 @@ local connection; local params = module:get_option("sql"); +local table_prefix = module:get_option_string("wordpress_table_prefix", "wp_"); local resolve_relative_path = require "core.configmanager".resolve_relative_path; @@ -80,7 +81,7 @@ end local function get_password(username) - local stmt, err = getsql("SELECT `user_pass` FROM `wp_users` WHERE `user_login`=?", username); + local stmt, err = getsql("SELECT `user_pass` FROM `"..table_prefix.."users` WHERE `user_login`=?", username); if stmt then for row in stmt:rows(true) do return row.user_password; @@ -190,7 +191,7 @@ end function provider.set_password(username, password) local hash = wordpressCreateHash(password); - local stmt, err = setsql("UPDATE `wp_users` SET `user_pass`=? WHERE `user_login`=?", hash, username); + local stmt, err = setsql("UPDATE `"..table_prefix.."users` SET `user_pass`=? WHERE `user_login`=?", hash, username); return stmt and true, err; end function provider.create_user(username, password)