OK,
I’m using WebloginPE on my site, and it’s working very well. I have a question, though.
Is there a way to allow users to modify their user group from the profile editing page?
Checked out the thread. Gave me some ideas. Thanks.
Trying to use the following code through a snippet inserted on my profile edit page.
Once the profile edit page is submitted, upon reload, I want to automatically change a user’s group (upgrade them) in the background. So, I’m trying to use the following mysql query to update their webgroup when the page reloads.
mysql_query("UPDATE modx_web_groups SET webgroup = ’4’ WHERE webuser = ’[+user.internalKey+]’ ");
Why will this not update their record?
If I substitute an actual webuser number instead of [+user.internalKey+] it works. However, I can place [+user.internalKey+] anywhere else in the snippet and it loads the users webuser # just fine.
I’ve also tried setting [+user.internalKey+] into a variable and inserting the variable into the webuser = portion of the query, but this seems to also be a no go.
Any ideas?
try this:
for logged in user
$table = $modx->getFullTableName( 'web_groups' );
$result = $modx->db->update( 'webgroup = 4', $table, 'webuser = "' . $modx->getLoginUserID() . '"' );
for other user
$table = $modx->getFullTableName( 'web_groups' );
$result = $modx->db->update( 'webgroup = 4', $table, 'webuser = "' . $_POST['the_name_of_your_webuser_input_field']. '"' );
see also modx api-pages:
http://wiki.modxcms.com/index.php/Category:API
Thank you very much. it appears that was exactly what I needed. It now appears to be functioning properly.
I literally spent hours trying to rewrite that query so that it would work and just couldn’t get it.
How would I adjust the code above (for logged in user) to check more than one condition?
I took a look at the Wiki, but, to be honest, although I sort of understand what it’s talking about, it’s a bit over my head. I’m kind of a PHP hack, not really a coder.