Skip to content

Instantly share code, notes, and snippets.

@Qubadi
Qubadi / gist:980775406cfde2a0bbe3b089c2b8835d
Created November 11, 2023 20:44
Delete user account and all posts. This custom code snippet enables user account deletion. Functionalities:
1. Allows logged-in users, except administrators, to delete their accounts.
Incorporates a nonce for security, ensuring the deletion request is valid and intentional.
Features a JavaScript confirmation dialog for users to confirm before proceeding with the deletion.
2. Deletes all posts and attachments created by the user, ensuring complete removal of their content from the website.
Finally, deletes the user's account from the WordPress system.
Security and Permissions:
3. Performs a security check using nonce verification to prevent unauthorized actions.
Restricts the ability to delete accounts to non-administrator users, ensuring only the account owner can initiate deletion.
4. Uses WordPress hooks and shortcodes for seamless integration into the WordPress environment.
Ensures the custom functions don't exist before defining them, avoiding conflicts with other plugins or themes.
@Qubadi
Qubadi / gist:581bf1f0a68876e0781a6aaff3d43c48
Last active September 5, 2024 12:14
Wordpress user, custom code ( Snippet PHP )display status account and Reactive/Deactive user name.
add_filter('manage_users_columns', 'add_custom_user_column');
function add_custom_user_column($columns) {
$columns['status'] = 'Status';
return $columns;
}
add_action('manage_users_custom_column', 'show_custom_user_column_content', 10, 3);
function show_custom_user_column_content($value, $column_name, $user_id) {
if ('status' == $column_name) {
$user = get_userdata($user_id);
@Qubadi
Qubadi / gist:e3a04065c01f67907715d17d180d8698
Last active July 24, 2024 21:34
Jetformbuilder convert email form to PDF ( Custom code )
1. Download the dompdf file, and add the file to wp-content and extract it after.
https://github.com/dompdf/dompdf/releases/download/v2.0.3/dompdf_2-0-3.zip
2. Dont forget to add subject line text in Jetformbuilder, and add it to this line:
$expected_subject_line = 'YOUR SUBJECT LINE TEXT, Or the form will not work. Cause its integrated by subject line text.
3. Change the url link for company logo to yours logo
4. Used hidden field for media, dont forget to add your on field name, and classname too.
Or u can use the same name i have added in allready. u have used fieldname: mediafield and classname: mediafield_classname
5. You dont need to add all the field name manually in Jetformbuilder sendmail content, u can add a text something like that only:
Hello,
@Qubadi
Qubadi / gist:60bfb11df4eab25efc0968bcce771048
Last active July 24, 2024 21:34
Jetformbuilder custom code and DomPDF file for Signature ( Esign )
Jetformbuilder custom code and DomPDF file for Signature ( Esign )
1. Create a Hidden field, and name the field name: signature, and CSS classname : signature-field, save and done.
2. Create your field, and then u dont need to add it to Jetformbuilder content manually, its now dynamicly by using the custom code.
In Content field, u can just add something like that:
Hello,
Thank you for your message. Please find the friends list attached for your reference.
@Qubadi
Qubadi / gist:e1fa473eefc84bacae1c242a1a6a1cc4
Last active January 28, 2025 11:55
Jetformbuilder form, A custom code for auto detect country and land code phone.
UPDATED 28/04/2024
__________________
Jetformbuilder form, A custom code for auto detect country and land code phone.
This code works for all Jetformbuilder.
The provided custom code is a PHP function for WordPress that adds international telephone input functionality to a website.
It includes CDN links for the necessary CSS and JavaScript files, applies custom styles for the phone input field,
and uses jQuery for dynamic behavior. The JavaScript part initializes the international telephone input with features
like auto-detecting the user's country using their IP address and updating the input field with the full phone number
@Qubadi
Qubadi / gist:ee5cea9a0187f8dd9e75bfb16ac9f1ec
Last active June 22, 2024 21:12
Jetformbuilder custom code to disable weekend date/days ( Date field )
1. First use the Datefield widget, and name it: date_field.
2. Then create a page to add your form, exemple: contact
3. A nonce for security is added.
4. Dont forget to add your page slug name in the code here:
function disable_weekends_in_datepicker() {
// Only load this script on the 'contact' page
if ( is_page('contact') ) {
?>
@Qubadi
Qubadi / gist:48174b21a5a28e93da7737835e31cccf
Last active May 9, 2025 00:40
Custom code for JetFormBuilder, designed to allow users to crop images.
UPDATED :
A new functionality for generating unique filenames for each cropped image
1. I've developed a new custom code for JetFormBuilder, designed to allow users to crop images.
I'm excited to share it with the group, making it accessible to most members here.
2. To begin, you'll need to create four fields: two media fields and two hidden fields. It's convenient to use the same
field names across these, so there's no need to modify the custom code.
@Qubadi
Qubadi / gist:1d01184fc7c42355979f52e361ffa58e
Last active September 5, 2024 12:12
Sends an email notification if new updates are available for plugins and theme
This code defines a function send_update_notification in a WordPress environment.
It checks for updates to plugins and themes, and sends an email notification if new updates are available.
For plugins, it uses get_site_transient('update_plugins') to check for plugin updates, and for themes,
it uses get_site_transient('update_themes'). If updates are found and have not been previously notified
(based on options stored in the database), it sends an email to a specified address with details about
the available updates. The function is hooked to the admin_init action, so it runs during the initialization of
the WordPress admin panel.
@Qubadi
Qubadi / gist:16201068d168313d43a8abbc3fff40ff
Last active January 20, 2024 04:17
Jetsmartfilters: This function is the core of the script. It checks whether all required fields are filled out
1. Add your page slug name, where you have the search form.
2. In summary, the script dynamically enables or disables the "Apply" button based on whether all
specified fields on the page are filled out, ensuring that the button is only clickable when all required fields have data.
function custom_required_field_script() {
// Only add this script on the specific page with the slug 'YOUR PAGE SLUG NAME/'
if (strpos($_SERVER['REQUEST_URI'], 'YOUR PAGE SLUG NAME/') !== false) {
?>
@Qubadi
Qubadi / gist:233a3a8f594b48d21ca366288a351ede
Last active October 31, 2024 10:34
JetEngine Listing Grid: Custom Post Types, Query Posts, and Products ,Drag-and-Drop Functionality on the Frontend
Video Tutorials here:
https://www.youtube.com/watch?v=hJhc90ETv0A
https://www.youtube.com/watch?v=ao8tlJ09Tc8
https://www.youtube.com/watch?v=BF7eernlAFA
function enqueue_drag_drop_script() {
if ( current_user_can( 'administrator' ) ) {
wp_enqueue_script('jquery-ui-sortable');