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!