I'm developing a content plugin to filter articles according to a field in CB profile.

Something like:

public function onContentPrepare ($context, &$article, &$params, $limitstart)
    ...code for CB setup...

Global $_CB_framework;
$cbUser =& CBuser::getInstance( $myId );

if ( ! $cbUser ) {
     $cbUser =& CBuser::getInstance( null );

//Select the value choosen by the user in a specific field
    $category = $cbUser->getField( 'cb_category' );
//Catch the category title
//Put the user value in $esc
    $esc= array ($category); 
//If the value of the user choice correspond to the name of the category
    if(in_array($cat, $esc) ) {

// Hide the entire article.
// Now what i do is hide title, text, hits and other properties of $article


    echo (' </br>Nothing to do</br>'); 

To hide all content I've tried to unset $article property like $article->text and it's work.

But...I need more...
I need to unset the entire $article object.

Unset or hide.
I've tried to change $article state property to state->0 (unpublished) but works like a simple label and the article was still displayed. Any idea about it?

Thanks in advance!

  • I don't understand why you need to unset anything. If you don't need to use any object values, simply don't use them. PHP's GC will deal with this after the script ends anyway
    – Lodder
    Dec 1, 2015 at 0:57

1 Answer 1


No you cannot unset the whole $article object, you can only unset its properties.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.