Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:03:58+00:00 2026-06-01T23:03:58+00:00

I’m trying to find out who is the user who last changed a document.

  • 0

I’m trying to find out who is the user who last changed a document.
Preferably, I would like to make collections based on this info…
All I can find is the Modification Date…

Using the script from this link, I do not seem to find the information on the last user in the metadata.

Is this correct( no modifying user info…), and if so, can it be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:03:59+00:00Added an answer on June 1, 2026 at 11:03 pm

    As @MikkoOhtamaa wrote, Plone doesn’t save the last modifier on object by default. But Plone does have version control enabled by default for Pages, News Items, Events and Link (by CMFEditions) and version metadata has the information of the latest modifier.

    If it’s OK to read the information from the version metadata and limit the feature only for version controlled content types, I think, you’d need to

    1. Register a new index (using catalog.xml in your add-on’s Generic Setup -profile; you may also want to register a metadata column to get the indexed data be returned in results):

      <?xml version="1.0"?>
      <object name="portal_catalog" meta_type="Plone Catalog Tool">
        <index name="last_modifier" meta_type="FieldIndex">
          <indexed_attr value="last_modifier"/>
        </index>
        <column value="last_modifier"/>
      </object>
      
    2. Register a custom search condition to be used in Topic-collections (using portal_atct.xml in your add-on’s Generic Setup -profile) and a metadata column to get the information listed on its tabular view:

      <?xml version="1.0"?>
      <atcttool>
        <topic_indexes>
          <index name="last_modifier"
                description="The last user, who has modified the object"
                friendlyName="Last Modifier"
                enabled="True">
            <criteria>ATCurrentAuthorCriterion</criteria>
            <criteria>ATListCriterion</criteria>
            <criteria>ATSimpleStringCriterion</criteria>
          </index>
        </topic_indexes>
        <topic_metadata>
          <metadata name="last_modifier"
                    description="The last user, who has modified the object"
                    friendlyName="Last Modifier"
                    enabled="True"/>
        </topic_metadata>
      </atcttool>
      
    3. Write a custom indexer, which looks up the last modifier from the version metadata and indexes it:

      # -*- coding: utf-8 -*-
      """Last modifier indexer"""
      
      from zope.component import getUtility
      
      from plone.indexer import indexer
      
      from Products.CMFCore.interfaces import ISiteRoot, IContentish
      from Products.CMFCore.utils import getToolByName
      
      
      @indexer(IContentish)
      def indexLastModifier(context):
          try:
              creator = context.Creators()[0]  # fallback value
          except AttributeError:
              creator = None
          except IndexError:
              creator = None
      
          site = getUtility(ISiteRoot)
          rt = getToolByName(site, "portal_repository")
      
          if rt is None or not rt.isVersionable(context):
              # not versionable; fallback to the creator
              return creator
      
          history = rt.getHistoryMetadata(context)
              if not history:
              # empty history; fallback to the creator
              return creator
      
          if not rt.isUpToDate(context):
              # history not up-to-date; fallback to the authenticated user
              mtool = getToolByName(site, "portal_membership")
              if mtool.isAnonymousUser():
                  # no authenticated user found; fallback to the creator
                  return creator
              else:
                  return mtool.getAuthenticatedMember().getId()
      
          length = history.getLength(countPurged=False)
      
          last = history.retrieve(length - 1)
          if not last or type(last) != dict:
              # unexpected version metadata; fallback to the creator
              return creator
      
          metadata = last.get("metadata")
          if not metadata or type(metadata) != dict:
              # unexpected version metadata; fallback to the creator
              return creator
      
          sys_metadata = metadata.get("sys_metadata")
          if not sys_metadata or type(sys_metadata) != dict:
              # unexpected version metadata; fallback to the creator
              return creator
      
          principal = sys_metadata.get("principal")
          if not principal or type(principal) != str:
              # unexpected version metadata; fallback to the creator
              return creator
      
          return principal
      
    4. And register the indexer in your add-on’s configure.zcml:

      <adapter name="last_modifier"
               factory=".indexers.indexLastModifier" />
      

    Be aware, though, that because the version control mechanism is triggered by the same events as catalog indexer, we may not be sure that the metadata for the most recent version exists when we are called to index it. Above, I apply dummy heuristics that when the repository says that the version history metadata is outdated when compared to the object to be indexed, I index the username of the current user instead (and expect that user been just editing the document).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.