If you was able to take User object, you may access custom fields like that $user->data()->get('my_not_sql_field'); $user->data()->set('my_not_sql_field', 'xxx')->update(); // update needs to be called once for entire record or $user->my_sql_field = 1; $user->update();
What code do I need to add so it can pull this data from the database? Something similar to the php include method in v3?
I created a page with this content, what do I need to add to link this to aMember? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test Index</title> </head> <body> <?php $user->my_sql_field = 1; $user->update();?> </body> </html>
So if I have a custom field called 'rewards' (not sql) and I am keeping a CSV list in it, how would I update it? Like this? $newreward = "20% off"; $currentrewards = $user->data()->get('rewards'); $newlist = $currentrewards.$newreward.","; $user->data()->set('rewards', $newlist)->update();
So I tried that and it threw me an error: Here's my whole code. line 16 is the "$currentrewards = $user->data()->get('rewards');" below. PHP: <?phpinclude '../members/bootstrap.php';if (isset($_POST["submit"])) {$name = $_POST["nm"];$cost = $_POST["cst"];$balance = Am_Di::getInstance()->plugins_misc->loadGet('points')->balance();$xml = simplexml_load_file('../rewards.xml');$avail;foreach ($xml->reward as $reward){if($reward['name'] == $name){$avail = $reward->avail;}}if ($cost <= $balance){Am_Di::getInstance()->plugins_misc->loadGet('points')->debit($cost, $name);$currentrewards = $user->data()->get('rewards');$newlist = $currentrewards.$name.",";$user->data()->set('rewards', $newlist)->update();header( 'Location: http://www.primitivesoultattoo.com/members/Artists-Page',TRUE,303 );}else{header( 'Location: http://www.primitivesoultattoo.com/members/Artists-Page',TRUE,303 );}}?>
You didn't initialize $user variable in your code. If you need to update user who is logged in currently: PHP: $user = Am_Di::getInstance()->authUser->getUser();if($user){ $rewards = $user->data()->get('rewards');// etc... }
So I initialized the user as you said and got: I used an echo statment to see where it was getting hung up exactly and it is the Does it matter that this file is located outside of the main amember folder? It's in a folder on the same site but in another folder other than the amember folder.