Skip to content

Instantly share code, notes, and snippets.

View hazratbilal0079's full-sized avatar
💭
I may be slow to respond.

Hazrat Bilal hazratbilal0079

💭
I may be slow to respond.
View GitHub Profile
@hazratbilal0079
hazratbilal0079 / Query to Check Duplicated Custom Post Types based on Terms and Meta Fields
Last active June 6, 2024 08:42
Query to Check Duplicated Custom Post Types based on Terms and Meta Fields
SELECT
p.ID AS post_id,
p.post_title,
p.post_author,
p.post_date,
tm1.name AS purpose,
tm2.name AS type_of_unit,
pm1.meta_value AS unit_number,
pm2.meta_value AS address_from_termlocation,
pm3.meta_value AS price,
@hazratbilal0079
hazratbilal0079 / Query to Check Duplicated in Custom Post Type based on the Meta Fields Only
Last active June 6, 2024 08:42
Query to Check Duplicated in Custom Post Type based on the Meta Fields Only
SELECT
p.ID AS post_id,
p.post_title,
pm1.meta_value AS property_name,
pm2.meta_value AS community_name,
pm3.meta_value AS type_owner_data,
pm4.meta_value AS area,
pm5.meta_value AS owner_number,
pm6.meta_value AS bedroom,
pm7.meta_value AS responsible_person,
@hazratbilal0079
hazratbilal0079 / Retrieve Distinct meta field values from Custom Post Type in WordPress
Last active June 6, 2024 08:42
Retrieve Distinct meta field values from Custom Post Type in WordPress
SELECT DISTINCT pm.meta_value AS your_meta_field_name
FROM wpd8_posts AS p
INNER JOIN wpd8_postmeta AS pm ON p.ID = pm.post_id
WHERE p.post_type = 'your_post_type_name' AND pm.meta_key = 'your_meta_field_name';
Example
SELECT DISTINCT pm.meta_value AS property_name
FROM wpd8_posts AS p
INNER JOIN wpd8_postmeta AS pm ON p.ID = pm.post_id
@hazratbilal0079
hazratbilal0079 / Dynamic Data Tables with Column Visibility Toggle and Print Feature (Crocoblock)
Last active October 26, 2024 13:54
Dynamic Data Tables with Column Visibility Toggle and Print Feature (Crocoblock)
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.0.8/css/dataTables.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/3.0.2/css/buttons.dataTables.css"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/2.0.8/js/dataTables.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.0.2/js/dataTables.buttons.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.print.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.colVis.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/l
@hazratbilal0079
hazratbilal0079 / Logout and Redirect to Specified Page Functionality for WordPress Logout Button without alert messages
Created June 6, 2024 08:41
Logout and Redirect to Specified Page Functionality for WordPress Logout Button without alert messages
-- Link on Button or Icon
https://yourwebsite.com/wp-login.php?action=logout
--Php Function or Code Snippet
add_action('check_admin_referer', 'logout_without_confirm', 10, 2);
function logout_without_confirm($action, $result)
{
@hazratbilal0079
hazratbilal0079 / WordPress Wpnonce Generation Shortcode and Handling in Bricks Builder
Last active June 6, 2024 08:46
WordPress Wpnonce Generation Shortcode and Handling in Bricks Builder
-- Shortcode
[wpnonce action='bricks-nonce-admin']
-- php Snippet or Code Snippet
// Function to generate the _wpnonce value
function generate_wpnonce_shortcode($atts) {
// Extract shortcode attributes, if any (default to 'bricks-nonce-admin' action)
@hazratbilal0079
hazratbilal0079 / Custom User Registration and Custom Role Assignment in WordPress with Meta Fields though hook
Created June 6, 2024 08:54
Custom User Registration and Custom Role Assignment in WordPress with Meta Fields though hook
--Hook name
registervisitor
--PHP Hook
add_action( 'jet-form-builder/custom-action/registervisitor', function( $request, $action_handler ) {
$username = sanitize_user($_POST['email']);
$email = sanitize_email($_POST['email']);
$first_name = sanitize_text_field($_POST['first-name']);
$user_status = sanitize_text_field($_POST['user-status']);
@hazratbilal0079
hazratbilal0079 / Creating Terms with or without Parent from Frontend in WordPress
Created June 6, 2024 08:59
Creating Terms with or without Parent from Frontend in WordPress
--Hook Name
create_terms
--PHP Hook
add_action( 'jet-form-builder/custom-action/create_terms', function( $request, $action_handler ) {
$terms = explode(',', $request['terms']);
$taxonomy = $request['tax']; // Replace with your actual taxonomy name
@hazratbilal0079
hazratbilal0079 / Assign Multiple Tickets or Properties or Update Single or Multiple Metafields from Frontend
Created June 6, 2024 09:05
Assign Multiple Tickets/Properties or Update Single or Multiple Metafields from Frontend in WordPress through hook or Code Snippet
--Hook Name
assignproperty
--Php Hook
add_action('jet-form-builder/custom-action/assignproperty', function($request, $action_handler) {
// Sanitize the input fields to prevent any security issues
$property_name = isset($_POST['select_property']) ? sanitize_text_field($_POST['select_property']) : '';
$community_name = isset($_POST['community-name']) ? sanitize_text_field($_POST['community-name']) : '';
$responsible_person = sanitize_text_field($_POST['responsible_person']);
@hazratbilal0079
hazratbilal0079 / Delete Multiple Tickets Based on Specified Criteria from a specific user or Delete All tickets of a user From Frontend in WordPress using hook or Code Snippet
Created June 6, 2024 09:17
Delete Multiple Tickets Based on Specified Criteria from a specific user or Delete All tickets of a user From Frontend in WordPress using hook or Code Snippet
--Hook Name
deleteownerdata
--PHP Hook
add_action('jet-form-builder/custom-action/deleteownerdata', function($request, $action_handler) {
// Sanitize the input fields to prevent any security issues
$property_name = isset($_POST['select_property']) ? sanitize_text_field($_POST['select_property']) : '';
$community_name = isset($_POST['community-name']) ? sanitize_text_field($_POST['community-name']) : '';
$responsible_person = sanitize_text_field($_POST['responsible_person']);