This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
OlderNewer