This don't work, I get blank page when entering shop. However I found bad(?) solution:
What I've done:
after $sql_ary I added: this thing collects data for inserting into acl_users, because If you never edited user permissions(only group permissions, etc.) you will need to add auth_option u_ which id is 85. Otherwise user won't be able to use purchased permissions. auth_option_id could be different so it would be great to create some query to select auth_option_id where auth_option = 'u_' from acl_options table.
Code: Select all
//Data for inserting u_ option
$sql_ary2 = array(
'user_id' => $user->data['user_id'],
'auth_option_id' => 85,
'auth_setting' => $auth_setting,
);
Then after
// Add the new permission for the user
$sql = 'INSERT INTO ' . ACL_USERS_TABLE . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$this->remove_item();
I added: if not exists I've inserted permissions to use user permissions(?), as I expressed myself above, without that other acl_users options won't work.
Code: Select all
//Add u_ option if not exists
$sql = 'INSERT IGNORE INTO ' . ACL_USERS_TABLE . $db->sql_build_array('INSERT', $sql_ary2);
$db->sql_query($sql);
$this->remove_item();
The last thing to get it work: purge
cache or reset user_permissions, so I tried to set user_permissions in user table to '' (empty) after user purchased permissions and it worked. However I am not php friendly
so had some errors making query.
Any issues about that? The first issue is that I have no idea about php, so the code need to be checked and the other issue that acl_users options are inserted twice(I think this is becouse I removed acl_users rows from table and not purged the
cache, so after any user activity in forum those acl_user options were restored from users_table user_permissions row back to acl_users table;
cache issue again)...