Home » Documentation » What is PeoplePods? » SDK Documentation » Object Definitions » $Obj » $Obj->set()

$Obj->set()

// $Obj->set($field,$value);
$person->set('nick','Chester');
$content->set('headline','Hello World!');
$group->set('groupname','Fish Lovers');
$comment->set('comment','Shut up!');
$file->set('file_name','img');

Set the value of $field to $value.

You may set values for native fields - those that exist in the pre-defined list of fields present in the database schema - or for meta fields which can be created at any time.

// set a real field
$doc->set('headline','This is a test');

// set a meta field
$doc->set('clown_nose','red');

You may specify that a value is NOT saved to the database by passing in an optional third parameter. Otherwise, values will be saved to the database upon calling the save() function.

// set a temporary field on a $person object

if ($person->get('id') == $POD->currentUser()->get('id')) {
  $person->set('isCurrentUser','1',false);
}

As of version 0.7, you no longer have to use the set method for basic content changes. You may now reference the field as if it was a native object attribute:

// set real fields
$content->headline = 'this is my headline';
$person->nick = 'chester';
$group->description = 'a group for cool kids';

// set meta fields
$content->endDate = '2012-12-31';
$person->aboutme = 'this is my bio';
  • Discuss This Document

Note to others (and myself): A temporary field comes in handy when one needs to display additional information in the output (through the themes), but the info shouldn't be saved into the object. e.g. $person->set('loginType','twitter',false); $person->output('login.oauth.php'); // login.oauth.php will display different info based on the loginType

Download Download the latest version of PeoplePods!

0.9 Latest Version:
Release Notes

Join the PeoplePods developer network and get direct access to documentation, additional plugins, and our forums!

  Already Registered? Login

Recent Posts from Our Blog

Version 0.9 is here!

The latest version of PeoplePods is now available for download! This version features a drastically revamped theme which is now valid HTML5, a completely rewritten JSON-powered API, many...

Ben Brown on how running a community is like throwing a giant, never-ending party

An interview I did with OpenSource.com is now online!  Read it here. In it, I discuss how running an online community is like throwing a giant, never-ending party, how open source techniques...