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

$Obj->addFlag()

$Obj->addFlag($flag,$person,$value=true);

Causes $person to add a flag named $flag to $Obj, with an optional value of $value. If no value is specified, it defaults to true.

To be clear, $person is the person object who is adding the flag. This is important to remember when adding flags to other person objects. The VAST majority of the time, the second parameter should be $POD->currentUser()

Some examples:


// flag a document as 'awesome'

$content->addFlag('awesome',$POD->currentUser());

// set a rating of 5 on a document
$content->addFlag('rating',$POD->currentUser(),5);

// set a 'block' flag on a person
$person->addFlag('block',$POD->currentUser());

Once a flag has been added, it can be referenced in your stack parameters:


// load all content with the awesome flag
$awesome = $POD->getContents(array(
  'flag.name'=>'awesome'
));

// load all content with a rating of 5
$top_rated = $POD->getContents(array(
  'flag.name'=>'rating',
  'flag.value'=>'5'
));

// load all people with the block flag
$blocked = $POD->getPeople(array(
  'flag.name'=>'block'
));

At this point, you can only refer to one flag at a time in your stack parameters. In some future version of PeoplePods, this may change.

Several flag names are reserved by PeoplePods for use in pre-defined stacks: friend, favorite, watching, and vote. You can use any other flag name to define your own functionality.

  • Discuss This Document

No comments have been posted yet.

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...