Tell us what you are trying to do?
I want the website administrator to be able to delete a user via a button located on a user profile sheet displayed in a view."
Is there any documentation that you are following?
https://toolset.com/forums/topic/add-the-link-delete-account/#post-606430
i've created a user edit form (id 30047) with this code :
[creduserform class='cred-user-form cred-keep-original']
[cred_field field='form_submit' value='Delete User' urlparam='' class='btn btn-primary btn-lg' output='bootstrap']
[/creduserform]
and puted this code in function.php
function bethesda_delete_user( $post_id, $form_data ){
if ( 30047 == $form_data['id'] ) {
require_once( ABSPATH.'wp-admin/includes/user.php' );
$current_user = get_current_user_id();
wp_delete_user( $current_user );
}
}
add_action( 'cred_submit_complete', 'bethesda_delete_user', 10, 2 );
the button appears in the view but when i click on it it reloads the page and nothing appears....
Hello,
The thread you mentioned above is for deleting current logged-in user.
In your case, you need to modify the custom PHP codes, see below test site:
1) Create a user form for editing user:
lien caché
2) In the user view, display above user form shortcode:
lien caché
[cred_user_form form='ad-a-delete-user-button' user='[wpv-user field="ID"]']
3) Setup the custom PHP codes as below:
lien caché
line 659~666
function bethesda_delete_user( $user_id, $form_data ){
if ( 43 == $form_data['id'] ) {
require_once( ABSPATH.'wp-admin/includes/user.php' );
wp_delete_user( $user_id );
}
}
add_action( 'cred_submit_complete', 'bethesda_delete_user', 10, 2 );
Test it in frontend:
lien caché
It works fine. For your reference.
can you give me the login and the pass for the test site ?