PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.9
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.9
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / front-end / default-fields / gdpr-delete / gdpr-delete.php

gdpr-delete.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.9.9, at front-end/default-fields/gdpr-delete/gdpr-delete.php

43 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4 /* handle field output */
5 function wppb_gdpr_delete_handler( $output, $form_location, $field, $user_id, $field_check_errors, $request_data ){
6 if ( $field['field'] == 'GDPR Delete Button' ){
7 if ( $form_location === 'edit_profile' ){
8 $item_title = apply_filters( 'wppb_'.$form_location.'_gdpr_delete_custom_field_'.$field['id'].'_item_title', wppb_icl_t( 'plugin profile-builder-pro', 'custom_field_'.$field['id'].'_title_translation', $field['field-title'], true ) );
9 $item_description = wppb_icl_t( 'plugin profile-builder-pro', 'custom_field_'.$field['id'].'_description_translation', $field['description'], true );
10
11 $edited_user_id = get_current_user_id();
12 if( ( !is_multisite() && current_user_can( 'edit_users' ) ) || ( is_multisite() && current_user_can( 'manage_network' ) ) ) {
13 if( isset( $_GET['edit_user'] ) && ! empty( $_GET['edit_user'] ) ){
14 $edited_user_id = absint( $_GET['edit_user'] );
15 }
16 }
17
18 $output = '
19 <label for="wppb-delete-account">'. wp_kses_post( $item_title ) .'</label>
20 <input class="wppb-delete-account" type="submit" value="'. __( 'Delete', 'profile-builder' ) .'" />';
21 $output .= '<span class="wppb-description-delimiter">'.trim( html_entity_decode ( $item_description ) ).'</span>';
22
23
24 $delete_url = add_query_arg( array(
25 'wppb_user' => $edited_user_id,
26 'wppb_action' => 'wppb_delete_user',
27 'wppb_nonce' => wp_create_nonce( 'wppb-user-own-account-deletion'),
28 ), home_url());
29
30 wp_enqueue_script( 'wppb-gdpr-delete-script', WPPB_PLUGIN_URL.'front-end/default-fields/gdpr-delete/gdpr-delete.js', array('jquery'), PROFILE_BUILDER_VERSION, true );
31 wp_localize_script('wppb-gdpr-delete-script', 'wppbGdpr', array(
32 'delete_url' => $delete_url,
33 'delete_text' => sprintf(__('Type %s to confirm deleting your account and all data associated with it:', 'profile-builder'), 'DELETE' ),
34 'delete_error_text' => sprintf(__('You did not type %s. Try again!', 'profile-builder'), 'DELETE' ),
35 ));
36
37 return apply_filters( 'wppb_'.$form_location.'_gdpr_delete_custom_field_'.$field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data );
38 }
39 }
40 }
41 add_filter( 'wppb_output_form_field_gdpr-delete-button', 'wppb_gdpr_delete_handler', 10, 6 );
42
43