SocialEngine Tutorial – Automatically post a status update / post to users wall on behalf of user using code behind

Sometimes you might need to post a status update on behalf of the user, say for example they have just completed an action or they’ve levelled up!

If you wish to post an update on behalf of the user you can use;

$action = Engine_Api::_()->getDbtable('actions', 'activity')->addActivity(Engine_Api::_()->user()->getViewer(), Engine_Api::_()->user()->getViewer(), 'status', 'YOUR STATUS TEXT HERE');

This creates a new user action stored under engine4_activity_actions which will then be posted on the current user’s wall.

*note this code is for use in a controller action only!

Socialengine Tutorial – Disable default css from being loaded

I’ve been working on creating a custom homepage which uses twitter bootstrap however I’ve found the default css being generated by the socialengine is interferring with the bootstrap css.

In order to stop socialengine from adding in the default theme css files head to

Application > Modules > Core > Layouts > Scripts > default-simple.tpl

This default simple is what is loaded on every page and then injected with the page’s content. However I didn’t want any of that to load on my landing page so I’ve done the following;

(In this file look for line 75 where the ‘linking’ of css files begins and I’ve wrapped it in an if statement which says if the current url string == the default home page (e.g. /) then don’t bother loading the rest of the php)

<?php // LINK/STYLES ?>
  $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
  if(trim($uri, '/') !=  trim($this->baseUrl(), '/')):
      'rel' => 'favicon',
      'href' => ( isset($this->layout()->favicon)
        ? $this->baseUrl() . $this->layout()->favicon
        : '/favicon.ico' ),
      'type' => 'image/x-icon'),
    $themes = array();
    if( !empty($this->layout()->themes) ) {
      $themes = $this->layout()->themes;
    } else {
      $themes = array('default');
    foreach( $themes as $theme ) {
    // Process
    foreach( $this->headLink()->getContainer() as $dat ) {
      if( !empty($dat->href) ) {
        if( false === strpos($dat->href, '?') ) {
          $dat->href .= '?c=' . $counter;
        } else {
          $dat->href .= '&c=' . $counter;
  <?php endif; ?>

Hope this helps 🙂