Attention

This document was written for an unsupported version of Plone, Plone 2.5.x, and was last updated 1607 days ago.

For more information, see the version support policy.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

How to create default content in Member Area

by Kees Hink last modified Dec 30, 2008 03:03 PM
Each member gets a member area created when they first log in. How to get certain content put in this folder by default?

Purpose

Suppose you want some default content placed in new members' home folder, just to help them along or because your site requires it for some purpose. For my use case, i want them to have a Bookmarks folder, hoping that this will draw their attention to this possibility.

Prerequisities

You should have knowledge about creating customized content types, and about adding content programmatically. This how-to is intended for use with Plone 2.5.

Step by step

  1. Via the ZMI, go to the portal_skins folder and select the custom folder.
  2. Add a notifyMemberAreaCreated script. This gets called by membership_tool when a new member first logs in. (Actually it gets called on the newly created member folder, acquisition will find the custom script.)

    # script to automatically create bookmarks folder in member's user area
    
    context.plone_log("Post create script running")
    bmId = 'bookmarks'
    bmTitle = 'My Bookmarks'
    context.invokeFactory('BookmarkFolder',id=bmId)
    bmfolder = getattr(context, bmId)
    bmfolder.setTitle(bmTitle)
    bmfolder.reindexObject()
    
    For this example to work, you should have ATBookmarks installed, otherwise, change it to Folder.

Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.