renventura / wp-delete-user-accounts

Allow your WordPress users to manually delete their own accounts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WP Delete User Accounts

Allow your users (except for administrators) to manually delete their own accounts. It uses the Sweet Alert jQuery plugin for slick-looking alerts and prompts.

Installation

Manually

  1. Download the zip file, unzip it and upload plugin folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress

Frequently Asked Questions

How do I use this plugin?

Install it, and let it run. There are no settings.

Hooks

wp_delete_user_accounts_shortcode_template (filter) Override the default template for shortcode output

Parameters: $path - (string) Path to the template $atts - (array) Shortcode attributes

Return: (string) Full path to new template file

Example: The following example shows you how to change the template path for the delete button. This is helpful for creating a custom button template.

add_filter( 'wp_delete_user_accounts_shortcode_template', 'wp_delete_user_accounts_custom_shortcode_template', 10, 2 );
/**
 *	Template path for the WP Delete User Accounts delete button
 *
 * 	@param string		$path 		Path to template file
 *	@param array 		$atts 		Shortcode attributes
 */
function wp_delete_user_accounts_custom_shortcode_template( $path, $atts ) {
	return get_stylesheet_directory() . '/templates/custom-shortcode.php' );
}

wp_delete_user_accounts_load_assets_on_frontend (filter) Load the plugin's CSS and Javascript files wherever you want. By default, the files are only loaded when the current post object's $post->post_content has the [wp_delete_user_accounts] shortcode.

Parameters: $load - (boolean) Whether the assets are to be loaded

Return: (boolean) Whether to load the files

Example: This example shows you how to add the CSS and JS files to the WooCommerce edit-account endpoint. This only loads the assets - it does not output the button. For an example of outputting the delete button, see the next example.

add_filter( 'wp_delete_user_accounts_load_assets_on_frontend', 'wp_delete_user_accounts_load_assets_on_woocommerce_edit_account' );
/**
 * Add the WP Delete User Accounts CSS and JS files to the WooCommerce edit-account endpoint
 *
 * @param  boolean 		$load 		Whether the assets are to be loaded (by default, will only load when post content has the [wp_delete_user_accounts] shortcode)
 *
 * @return boolean
 */
function wp_delete_user_accounts_load_assets_on_woocommerce_edit_account( $load ) {
	return is_wc_endpoint_url( 'edit-account' ) ? true : $load;
}

This shows you how to add the delete button to a WooCommerce template using a WooCommerce hook (in this example, )

add_action( 'woocommerce_after_edit_account_form', 'wp_delete_user_accounts_delete_button_after_edit_account' );
/**
 * Output the WP Delete User Accounts delete button after the edit-account form in WooCommerce
 * @author  Ren Ventura <renventura.com>
 */
function wp_delete_user_accounts_delete_button_after_edit_account() {
	echo do_shortcode('[wp_delete_user_accounts]');
}

Bugs

If you find an issue, let me know!

Changelog

1.2.3

  • WP Tested Up To 6.0

1.2.2

  • Remove wp_logout(), which was causing processing to get stuck
  • Use $.ajax() instead of $.post()

1.2.1

  • Made the DELETE text (for confirming account deletion) translatable

1.2

  • Added filter for modifying script localization variables (e.g. the redirect URL)

1.1.1

  • Updated translatable strings

1.1.0

  • Added filter for loading CSS and JS assets anywhere on the frontend (e.g. within WooCommerce templates).

1.0.3

  • Changed plugin text domain to dirname instead of basename to remove .php extension from path

1.0.2

  • Add POT file for translations

1.0.1

  • Fixed dependency array on enqueues

1.0

  • Initial version

About

Allow your WordPress users to manually delete their own accounts.

License:GNU General Public License v2.0


Languages

Language:PHP 73.1%Language:JavaScript 26.9%