Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User delete workflow fixes for #1365 #1404

Merged
merged 5 commits into from
Jul 30, 2021

Conversation

micahmills
Copy link
Collaborator

adds a function on the 'delete_user' hook to delete the 'correspons_t…o_user' meta key and value.

functions.php Outdated Show resolved Hide resolved
@corsacca
Copy link
Member

corsacca commented Jun 1, 2021

Thanks @micahmills !
We can put this function in dt-users/users.php

@corsacca corsacca linked an issue Jun 1, 2021 that may be closed by this pull request
@corsacca
Copy link
Member

corsacca commented Jun 1, 2021

If a user is deleted from the network side, this might need to run on each subsite.

@micahmills
Copy link
Collaborator Author

According to the Wordpress codex (https://developer.wordpress.org/reference/hooks/delete_user/) doesn't run on all multisite situations when a user is deleted, but if we change to the 'deleted_user' hook it should run. I will play with it and see what it does.

…eleted_user` so it should run on multisite setups.
@micahmills micahmills requested a review from corsacca June 2, 2021 09:53
@micahmills
Copy link
Collaborator Author

Something to note here is that the record type continues to be a 'user.' We could revert it to another user type in this function, but there are possible security concerns with changing it to an access record when it should be a private record.

@corsacca
Copy link
Member

corsacca commented Jun 2, 2021

According to the Wordpress codex (https://developer.wordpress.org/reference/hooks/delete_user/) doesn't run on all multisite situations when a user is deleted, but if we change to the 'deleted_user' hook it should run. I will play with it and see what it does.

deleted_user Fires immediately after a user is deleted from the database.

i wonder if the remove_user_from_blog hook would work better. It would be called for each site

(both strategies would be needed, so it works on multi and single sites.)

@corsacca
Copy link
Member

corsacca commented Jun 2, 2021

Something to note here is that the record type continues to be a 'user.' We could revert it to another user type in this function, but there are possible security concerns with changing it to an access record when it should be a private record.

Yeah. i don't know how best to solve this one. I think we keep it as a user record and change the status to archived.

@prykon
Copy link
Collaborator

prykon commented Jul 22, 2021

I'm able to delete a user and then re-create it for the same contact, but there's a new bug:
The display name gets ignored. I set a display name for the user but it still shows the contact name. This worked fine with the previous code.

@micahmills
Copy link
Collaborator Author

Where is the display name not displaying?

@prykon
Copy link
Collaborator

prykon commented Jul 22, 2021

In the contacts page and in the contact details page.
It does, however, appear in the wp-admin/users.php and in user-management/users/

@corsacca corsacca merged commit 511feaa into DiscipleTools:master Jul 30, 2021
@corsacca
Copy link
Member

thanks @micahmills and @prykon !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete user doesn't remove relevant user meta from database
3 participants