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 মানে হল মাস্ট ইউজ প্লাগিন। মানে এই ডিরেক্টরিতে থাকা পিএইচপি ফাইলগুলা ওয়ার্ডপ্রেসের সাথে ডিফল্টভাবেই লোড হবে। এইগুলাকে ডিএকটিভ করা সম্ভব না যতক্ষণ আপনি ডিলিট করছেন। মূলত এই ডিরেক্টরির বিভিন্ন প্লাটফর্ম প্রোভাইডাররা ইউজ করে ক্যাশ, সিকিউরিটি এইসব ইউজারের হাতে ছেড়ে না দিয়ে।

WordPress redirect to a specific page

function redirect_specific_page() {
    // Check if the current page is the one you want to redirect and user is logged in
    if ( is_page( 'page-slug' ) && is_user_logged_in() ) {
        // Redirect to the desired URL
        wp_redirect( 'https://example.com/new-page/' );
        exit;
    }
}
add_action( 'template_redirect', 'redirect_specific_page' );

Instead of slug, we can use page id there.

To pass elementor

if ( is_page( 123 ) && is_user_logged_in() && ! is_admin() && ! is_customize_preview() && ! ( is_plugin_active( 'elementor/elementor.php' ) && \Elementor\Plugin::$instance->editor->is_edit_mode() ) )

OR

if ( is_page( '13446' ) && is_user_logged_in() && !is_customize_preview() && !\Elementor\Plugin::$instance->editor->is_edit_mode() && !\Elementor\Plugin::$instance->preview->is_preview_mode() )

How To Remove The Divi Blog Module Meta Separators

Blog module settings>Advanced tab>CSS IDs & Classes and add “pa-remove-meta-separators” to the CSS Class input field.

<script>
    //Remove meta seperator pipes (|) and by from Divi Blog module meta
    jQuery(function($) {
        $(document).ready(function() {
            $('.pa-remove-meta-separators .post-meta').each(function() {
                $(this).html($(this).html().replace(/\|/g, " "));
                $(this).html($(this).html().replace('by', " "));
                $(this).html(jQuery(this).html().replace(/,/g, ""));
            });

            //Do the same for ajax with pagination enabled
            $(document).bind('ready ajaxComplete', function() {
                $('.pa-remove-meta-separators .post-meta').each(function() {
                    $(this).html($(this).html().replace(/\|/g, " "));
                    $(this).html($(this).html().replace('by', " "));
                    $(this).html(jQuery(this).html().replace(/,/g, ""));
                });
            });
      });
    });
</script>

Redirect to parent window

add_action( 'wp_footer', function () { ?>
<script>
	jQuery( window ).on( "load", function() {
		
		var ifrm = document.getElementById('ChildCareCRM');
		//var base = doc.createElement("base");
   		ifrm.contentDocument.baseURI = document.baseURI;
		//ifrm.contentDocument.querySelector("head").appendChild(base);
		//var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
		//iframeDoc.getElementById('form').setAttribute('target','_parent');
		
		//jQuery( "#ChildCareCRM" ).contents().find( "#form" ).attr('target','_parent');
		//console.log(jQuery( "#ChildCareCRM" ).contents().find( "form" ).attr('target'));
	});
</script>
<?php }, 100  );