Skip Navigation

[Resolved] Delete User link not working

This support ticket is created 3 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 12 replies, has 2 voices.

Last updated by jamesR-13 3 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#2101403

Trying to implement a way for administrative users to remove other users via front end

Following thread here:
https://toolset.com/forums/topic/administrators-and-editors-option-to-delete-other-user-on-the-frontend/

I have added the code to functions.php, added the generic field with the user id and the submit button to the form, added the form to the loop. Form fires when submit is clicked, but user account is not deleted. I have updated the form ID in the code snippet.

Not sure what i am missing. Please enable private reply fields so I can give access. Thank you!

#2101559

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Please allow me to have admin access to the site and a link to where the form is so that I can have a look at this one for you.

Thanks,
Shane

#2102423

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

I'm still looking into this for you, however what i've found is that the Hook isn't being triggered.

If I have any update for you I will let you know.
Thanks,
Shane

#2102429

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

I'm still looking into this for you, however what i've found is that the Hook isn't being triggered.

If I have any update for you I will let you know.
Thanks,
Shane

#2102431

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Are you able to provide FTP access to the site ? If you take a look at your functions.php file in the child theme you will notice that I added a die() function. Can you remove it ?

This was added as a test to see if the functions.php file is being loaded correctly, however because of this i'm not able to access the site.

Please let me know once you've removed it.

Thanks,
Shane

#2102437

It's removed and the site is working again.

#2102543

Do you still need FTP access?

#2102545

Do you still need FTP access, Shane?

#2102597

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Yes please provide the FTP access .

I've enabled the private fields for your next response.

Thanks,
Shane

#2103289

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

This should now be working.

Not sure why your first form wasn't triggering the hook but now that i've created a completely new for you are now able to delete your users.

The updated code is now this.

/**
 * Hook into CRED Edit User form submission
 * to delete current user
 */
function tssupp_delete_user( $user_id, $form_data ){
   
    if ( $form_data['id'] == 4809  ) {
        require_once( ABSPATH.'wp-admin/includes/user.php' );
       wp_delete_user( $user_id );
    }
}
add_action( 'cred_save_data', 'tssupp_delete_user', 10, 2 );

Also you can pass the ID of the user directly to the form by doing it like this.

[cred_user_form form='delete-user-2' user="[wpv-user field='ID']"]

Please let me know if this helps.
Thanks,
Shane

#2103291

ok, cool.

So, just so I understand, I don't NEED the intermediate generic field, is that correct?

#2103293

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

That is correct.

If you check the new form that I created "Delete User 2" you will notice that it only has the submit button.

Given that the ID is being passed directly to the form no intermediary field is required to hold the user's ID.

Thanks,
Shane

#2104959

My issue is resolved now. Thank you!