Reputation: 27
I am new to wordpress hooks and I am trying to delete a wordpress user using a custom action the plugin Restrict Content Pro provides. (https://docs.restrictcontentpro.com/article/2054-group-accounts-actions-filters) What I want to achieve: When a member is removed from a group, their account should be deleted. Unfortunately my code doesn't work. Any ideas on how to modify it be highly appreciated!
function delete_group_user() {
wp_delete_user($user_id->ID );
}
add_action( 'rcpga_remove_member', 'delete_group_user' );
Upvotes: 0
Views: 405
Reputation: 2352
You are close, your function delete_group_user()
does not have $user_id
defined. Luckily, it looks like the rcpga_remove_member
hook provides that information. Something like this should work:
function delete_group_user($user_id) {
wp_delete_user($user_id);
}
add_action( 'rcpga_remove_member', 'delete_group_user' );
Also, note from the documentation that $user_id
is an INT not an object.
Upvotes: 1