We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20532
    • 14 Posts
    Any clues as to how to create a snippet that returns the edited by name? I plan to call this in an rss feed for recently updated content.

    I know editedby returns the id. I then need to convert this to a name.

    Here’s a bit I found that is used on a manager page and it may be related:

    // Get Editor's username
    $rs = mysql_query('SELECT username FROM '.$tbl_manager_users.' WHERE id=\''.$content['editedby'].'\'');
    if ($row = mysql_fetch_assoc($rs))
    	$editedbyname = $row['username'];
    echo $editedbyname;
    


    Thanks!
      • 1122
      • 209 Posts
      MODx API has a special function for this purpose "getUserInfo". It returns user’s record:
      <?php
      $editedby_id = <obtain-editedby-field-of-the-document>;
      // sample conversion
      $user_info = $modx->getUserInfo($editedby_id);
      $editedby_name = ($user_info['fullname'] ? $user_info['fullname'] : $user_info['username']);
      ?>
      

      This code converts editedby id to user’s full name or user’s login (if the former was not set).
        • 20532
        • 14 Posts
        Right on. Thanks for the help!