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

$Obj->addMeta()

// $Obj->addMeta($field,$value);
$person->addMeta('about_me','I live in Austin');
$content->addMeta('endDate','2012-12-31');
$group->addMeta('motto','Stay Classy');

Add a meta field to the object named $field with the value $value. This new field will be saved to the database immediately if the object has already been saved, or upon first save.

Most of the time, this function should not be called directly, as it is automatically called when necessary by the $obj->set() function.

However, to access some specialized functionality, you can call it directly. For example, if you want to strip $value of any HTML, an optional third parameter can be passed:

// value will be stripped of html
$person->addMeta('tagline','I am putting <b>bold tags!</b>',true); 

Meta fields cannot contain blank strings or null values. Setting a meta field to a blank value will result in it being removed.

There is ONE reserved meta field name: adminUser. This field has a special meaning, and thus, you should not mess with it. Seriously!

Once you've added a meta field, you can refer to it in your stack parameters as if it were a native field:

$content->addMeta('transaction_status','active');

// get all content that has a meta field named
// transaction_status that is set to 'active'
$active_transactions = $POD->getContents(array(
   'transaction_status'=>'active'
));

You can also just look for the existence of a meta field:

// get content that has a sidebar field.
$content_with_sidebars = $POD->getContents(array(
  'sidebar:!='=>'null'
));

Read more about Meta Fields.

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