// Gravity form Require login pre download
add_filter('gform_require_login_pre_download', function ($require_login) {
$require_login = true;
if (! is_user_logged_in()) {
auth_redirect();
}
return $require_login;
});
Hide Drop Down date with CSS
/* Gravity form (Launchpad book a tour) Hide Drop-down years keeping first 11 options */
select#input_7_9_3 *:nth-child(n+12),select#input_7_14_3 *:nth-child(n+12),select#input_7_19_3 *:nth-child(n+12) {
display: none;
}
Gravity form hide past date & restrict min and max date
<script>
gform.addFilter('gform_datepicker_options_pre_init', function(optionsObj, formId, fieldId) {
// Apply to field 23 in form 7 or form 9
if ((fieldId == 23) && (formId == 9)) {
// Disable past dates
optionsObj.minDate = 0;
// Restrict to Tuesday (2), Wednesday (3), and Thursday (4)
optionsObj.beforeShowDay = function(date) {
var day = date.getDay(); // 0 = Sunday, 1 = Monday, ..., 6 = Saturday
return [day === 1 || day === 2 || day === 3 || day === 4 || day === 5]; // Allow only Tue, Wed, Thu
};
}
if ((fieldId == 9 || fieldId == 14 || fieldId == 19) && (formId == 9)) {
optionsObj.maxDate = 0;
}
return optionsObj;
});
</script>
Gravity form Hide Past Date and Restrict days
<script>
gform.addFilter('gform_datepicker_options_pre_init', function(optionsObj, formId, fieldId) {
// Apply to field 23 in form 7 or form 9
if ((fieldId == 23) && (formId == 7 || formId == 9)) {
// Disable past dates
optionsObj.minDate = 0;
// Restrict to Tuesday (2), Wednesday (3), and Thursday (4)
optionsObj.beforeShowDay = function(date) {
var day = date.getDay(); // 0 = Sunday, 1 = Monday, ..., 6 = Saturday
return [day === 2 || day === 3 || day === 4]; // Allow only Tue, Wed, Thu
};
}
return optionsObj;
});
</script>
Create WP users with FTP access
অনেক সময় এই কাজটি দরকার পড়ে, বিশেষ করে যারা বিভিন্ন মার্কেটপ্লেসে কাজ করেন। ক্লায়েন্ট শুধুমাত্র এফটিপি বা ফাইল ম্যানেজার অ্যাক্সেস দিয়ে থাকে। তবে খেয়াল রাখতে হবে, অ্যাডমিন অ্যাক্সেস নেওয়ার পরে এই কোড/ফাইলটি রিমুভ করে নিতে হবে। তাছাড়া, অনেক সময় অতিরিক্ত সিকিউরিটি ব্যবস্থা থাকলে এই পদ্ধতি কাজ নাও করতে পারে। সে জন্য প্রচলিত অন্য পদ্ধতিগুলোও ব্যবহার করা যায়।”
আপনার ওয়েবসাইটের ‘wp-content’ ডিরেক্টরির মধ্যে একটি নতুন ডিরেক্টরি তৈরি করুন ‘mu-plugins’ নামে। এবার mu-plugins এর ভেতরে একটি ফাইল তৈরি করুন ‘create-admin-user.php’ নামে। এই ফাইলে নিচের কোড লিখুনঃ
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = 'webmaster@mydomain.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
} );
উপরের কোডে ইউজারনেম, পাসওয়ার্ড, ইমেইল আপনার পছন্দমতো দিন:
$username: আপনার নতুন অ্যাডমিন ইউজারনেম
$password: নতুন অ্যাডমিন ইউজারের জন্য একটি পাসওয়ার্ড দিন
$email_address: অ্যাডমিন ইউজারের সাথে সংশ্লিষ্ট একটি ইমেইল দিন
কাজ শেষ। এবার লগইন চেষ্টা করুন। লগইন সফল হলে create-admin-user.php ফাইলটি রিমুভ করুন।
mu-plugins মানে হল মাস্ট ইউজ প্লাগিন। মানে এই ডিরেক্টরিতে থাকা পিএইচপি ফাইলগুলা ওয়ার্ডপ্রেসের সাথে ডিফল্টভাবেই লোড হবে। এইগুলাকে ডিএকটিভ করা সম্ভব না যতক্ষণ আপনি ডিলিট করছেন। মূলত এই ডিরেক্টরির বিভিন্ন প্লাটফর্ম প্রোভাইডাররা ইউজ করে ক্যাশ, সিকিউরিটি এইসব ইউজারের হাতে ছেড়ে না দিয়ে।
Gravity form enable CC field to notification
add_filter( 'gform_notification_enable_cc', '__return_true' );
Gravity form Date Drop Down Year Hide
select#input_7_9_3 *:nth-child(n+11) {
display: none;
}
WordPress import posts with media and featured image
Step 1: Install the plugin Export media with selected content to the old site and export the post. Check Export media with selected content when exporting.
Step 2: Install Auto Upload Images to the new site and import the file.
Enjoy!
JQuery Check if cookie exists
<script>
jQuery(document).ready(function ($) {
// Function to check if a cookie exists
function checkCookie(name) {
return document.cookie.split(";").some(function (item) {
return item.trim().indexOf(name + "=") == 0;
});
}
// Check if the cookie exists
if (checkCookie("parent_corner_show_content")) {
// If the cookie exists, hide the section
$("#parent_corner_form_section").hide();
$("#parent_corner_contents_section").show();
}
});
</script>
Gravity form set cookies after confirmaiton
// Gravity form set cookies after confirmaiton
add_action( 'gform_confirmation', 'set_cookie_after_confirmation', 10, 4 );
function set_cookie_after_confirmation( $confirmation, $form, $entry, $ajax ) {
?>
<script type="text/javascript">
// Function to set the cookie
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
// Set your cookie here
setCookie('parent_corner_show_content', 'true', 30); // Change 'your_cookie_name' and 'your_cookie_value' accordingly
</script>
<?php
return $confirmation;
}