TSP Posted November 2, 2015 Share Posted November 2, 2015 When members are deleted in IPS 4 the posts simply get the name "Guest". Which on a helpfulness scale from 0 to 10 is 0... I wish to change this to be set to "Guest_Thedeletedname". Like it was in IPS 4, but I can't find where the rows are updated to be guest posts. Link to comment Share on other sites More sharing options...
Adriano Faria Posted November 2, 2015 Share Posted November 2, 2015 It sets member_id = 0. When displaying the name, if member_id = 0 then show the language bit guest. Probably that's how it's done. I think there's a task for this, since the content is not deleted in same time. Link to comment Share on other sites More sharing options...
TSP Posted November 2, 2015 Author Share Posted November 2, 2015 Aww man, I've been chasing this for one and a half hour now. I've created and deleted like 10+ test users on my test site. Turns out: 1. When you delete a member and their posts are kept, it does a call to hideOrDeleteAllContent from the delete-method in system/Member/Member.php public function delete( $setAuthorToGuest = TRUE ) { if( $setAuthorToGuest ) { /* Clean up content - set to member ID 0 - We check $setAuthorToGuest because of member merging. As the member is immediately deleted we do not want to compete with the existing merge in progress. */ $this->hideOrDeleteAllContent('merge', array('merge_with_id' => 0, 'merge_with_name' => '' )); } Make a note of the merge_with_name here... Which in turn creates a task: \IPS\Task::queue( 'core', 'MemberContent', array_merge( array( 'initiated_by_member_id' => \IPS\Member::loggedIn()->member_id, 'member_id' => $this->member_id, 'name' => $this->name, 'class' => $class, 'action' => $action ), $extra ), 1 ); Which is handled in applications/core/extensions/core/Queue/MemberContent.php You would believe that the 'merge_with_name' value sent to the MemberContent-task would be used to set the name of the posts to that name, like I believed at first... In which case I would only have to update from 'merge_with_name' => '' to 'merge_with_name' => $this->name. But no, that value isn't used at all in MemberContent.php. case 'merge': $item->changeAuthor( \IPS\Member::load( $data['merge_with_id'] ) ); break; } So at this point I tried to change it to: case 'merge': $member = \IPS\Member::load( $data['merge_with_id'] ); if ( $data['merge_with_name'] ) { $member->name = $data['merge_with_name']; } $item->changeAuthor( $member ); break; Which seems sensible and I thought that would surely fix it so it would set it to the name defined from HideOrDeleteContent in the Member-class. But no... Because in the changeAuthor-method in system/Content/Content.php, this is done: case 'author_name': $this->$col = $newAuthor->member_id ? $newAuthor->name : ''; break; Something seems really wrong here. I mean it can't be intended that posts written by deleted members are losing the name on the post content when the member is deleted? That's just silly. Link to comment Share on other sites More sharing options...
pequeno Posted September 27, 2016 Share Posted September 27, 2016 Hello @TSP, Have you found a way to keep the username when you delete this member? I don´t like to put "Guest" in deleted member messages. Greetings. Link to comment Share on other sites More sharing options...
TSP Posted September 27, 2016 Author Share Posted September 27, 2016 39 minutes ago, pequeno said: Hello @TSP, Have you found a way to keep the username when you delete this member? I don´t like to put "Guest" in deleted member messages. Greetings. For the section I mentioned in system/Content/Content.php that I mentioned above I ended up replacing it with: (I also kept the other two changes mentioned in my previous reply) case 'author_name': /* HW_CUSTOM: Guestname on deletion */ if ( $newAuthor->member_id or ( ! $newAuthor->member_id and strlen( $newAuthor->name ) == 32 ) ) { /* Default */ $newGuestName = isset($newAuthor->_data['name']) ? $newAuthor->_data['name'] : ''; $this->$col = $newAuthor->member_id ? $newAuthor->name : $newGuestName; } else { $this->$col = $newAuthor->name ? $newAuthor->name : ''; } break; Apparently an official fix will be coming for 4.1.16 though. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.