Skip to content

Instantly share code, notes, and snippets.

@Qubadi
Qubadi / gist:436b3974752f4bc659b15db1ea8033f2
Created November 6, 2023 08:45
Jetengine ProfileBuilder account, logout button, custom code ( PHP snippet code )
function custom_logout_shortcode() {
// Register and enqueue a custom stylesheet in the WordPress admin
wp_register_style('custom-logout-style', false);
wp_enqueue_style('custom-logout-style');
// Add inline CSS to the custom stylesheet
$css = '
.custom-logout-link {
font-size: 16px !important;
font-weight: 700 !important;
color: #171429 !important;
@Qubadi
Qubadi / gist:6bb6b76e070d96c5076da748b0e5b872
Created November 6, 2023 08:46
Jetengine WordPress post or custom post type when the post is permanently deleted. It also includes functionality to handle meta fields for galleries, ensuring that all related images are thoroughly deleted.
add_action('before_delete_post', function ($post_id) {
// If you want to restrict this to just the 'cpt slug' post type, uncomment the following line:
// if (get_post_type($post_id) !== 'ADD YOUR CPT SLUG') return;
// Delete the featured image (post thumbnail).
$thumbnail_id = get_post_thumbnail_id($post_id);
if ($thumbnail_id) {
wp_delete_attachment($thumbnail_id, true);
}
// Handle the deletion of gallery images stored in the 'gallery' custom field.
$gallery_images = get_post_meta($post_id, 'ADD YOUR META FIELD GALLERY', true);
@Qubadi
Qubadi / gist:5cc4ff6ddb6ed13a1175dc631dc0f844
Last active March 1, 2024 16:21
Sending a verification code upon user registration. Creating a shortcode for the verification form. Handling the form submission via AJAX. Adding a custom column to the user list to show account status. Checking the verification status during the login process. Automatically logging out unverified users.
UPDATED
-----------------
Dont forget to use the shortcode:
[verify_user_account]
Change this ; https://your-domain-name.com/your-verfi-page-name-slug to yours url
Custom code :
// Hook into user registration to generate and send the verification code
add_action('user_register', 'send_verification_code', 10, 1);
@Qubadi
Qubadi / gist:e6da6e619fb7516fa902a27e26d68a7f
Created November 6, 2023 14:04
When a product is deleted, this code will work to remove the featured image and gallery images of a WooCommerce product from the WordPress media library
add_action('before_delete_post', function ($post_id) {
// Check if the post being deleted is a WooCommerce product
if (get_post_type($post_id) !== 'product') {
return;
}
// Delete the featured image (post thumbnail) if it exists
$thumbnail_id = get_post_thumbnail_id($post_id);
if (!empty($thumbnail_id)) {
wp_delete_attachment($thumbnail_id, true);
@Qubadi
Qubadi / gist:d6375ff27c1044416a665af09a294e80
Created November 6, 2023 20:17
Jetformbuilder add icon to the form input field.
Dont forget to change the form field to your fields.
function enqueue_icons_script_and_styles() {
// Enqueue the Font Awesome stylesheet for the icons
wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css');
// Add inline styles
$custom_css = "
.input-icon {
@Qubadi
Qubadi / gist:af9753eae713ee66b3039279b6073902
Created November 7, 2023 08:00
Jetbooking + Woocommerce, display check in and check out orders my account.
function add_check_in_out_column_title($columns) {
$new_columns = array();
foreach ($columns as $key => $name) {
$new_columns[$key] = $name;
if ('order-number' === $key) {
$new_columns['order-check-in-out'] = 'Check in / out';
}
}
return $new_columns;
@Qubadi
Qubadi / gist:f5b051f218d041fba58b6cae805916a7
Last active January 15, 2024 09:32
Hide / Removing specific elements for users who are not logged in by ID.
Dont forget to change ID #my-hide-1 to your CSS IDs
The custom code is a WordPress PHP script that securely modifies a webpage's HTML by removing specific elements for users who are not
logged in. It initiates an output buffer to capture the page content, then processes and filters it based on element IDs before the
content is rendered in the browser. This ensures that certain parts of the page are hidden from public view, enhancing privacy and
security.
@Qubadi
Qubadi / gist:8a83347e838db08fcd90fe01a5818133
Created November 10, 2023 02:15
Add custom input field CSS ID for menu.
1. Adding a custom input field for the CSS ID in the menu item settings.
2. Saving the CSS ID entered by the user when the menu item is updated.
3. Inserting the saved CSS ID into the menu item's HTML output on the website.
Essentially, it's a way to enhance menu items with custom IDs for more precise styling and interaction handling.
// Add custom fields to menu item
@Qubadi
Qubadi / gist:c33ad20bcef087795b333d55d172bed5
Created November 11, 2023 20:41
This custom code( Snippet code ) enables user account deactivation. It prevents direct access for security and provides the following functionalities:
Deactive user account.
This custom code( Snippet code ) enables user account deactivation. It prevents direct access for security and provides the following functionalities:
1. User Account Deactivation: Logged-in users, except administrators, can deactivate their accounts through a generated link. This process includes a security check (nonce) and a confirmation step.
2. Admin-Led Reactivation: Administrators can reactivate user accounts.
3. User Interface Enhancements: Adds new columns in the admin area to show user account statuses and provide reactivation links.
4. Login Restriction: Prevents deactivated users from logging in.
WordPress Integration: Uses WordPress hooks for seamless integration with the user management system.
Shortcode: [custom_deactive]
@Qubadi
Qubadi / gist:55a3c3e57a173cf0c5846524c1d7d3d4
Created November 11, 2023 20:43
Delete user account and keep the posts. This custom code snippet enables user account deletion.
Delete user account and keep the posts.
This custom code snippet enables user account deletion.
Functionalities:
1. User Account Deletion: Allows logged-in users, except administrators, to delete their accounts. It includes a security check (nonce)
and a confirmation dialog to confirm the user's intention.
2. Content Preservation: On account deletion, the user's content (posts and links) is preserved by unassigning it, rather than deleting it.
3. Security and Integration: Implements a security check to prevent unauthorized access and integrates with WordPress using hooks and shortcodes.
4. Custom Deletion Process: Instead of using WordPress's default user deletion function, it employs a custom method to delete user data while
keeping their posts and links intact.