WebsiteWordpressآموزش ها

نحوه مخفی کردن یا تغییر فرم و پیام محافظت شده با رمز عبور در وردپرس

How to Hide or Change Password Protected Message and Form in WordPress

نحوه تغییر پیام پیش فرض در پست/صفحه محافظت شده با رمز عبور در وردپرس

/**
 * Password Protected Message
 */

function my_custom_password_form() {
  
    global $post;

    // Custom logic for the message
    $password_form_message = 
    __( '<p id="private-area-message">This is my new message for the protected area. If you would like access to this page, please send an email to <strong><a href="hello@axio.ir">hello@axio.ir</a></strong></p>' );

    // Put together the custom form using the dynamic message
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $form = '<div class="container"><form class="protected-post-form" action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
    ' . $password_form_message . '
    <label id="password-label" for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" class="pw-window" type="password" size="20" /><input type="submit" class="btn btn-large" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
    </form></div>
    ';
    return $form;

}
add_filter( 'the_password_form', 'my_custom_password_form' );

پنهان کردن پیام محافظت شده با رمز عبور

برای انجام این کار، می‌توانیم از همان کدی که در بالا استفاده کردیم استفاده کنیم، تنها چیزی که باید تغییر دهیم مقدار $password_form_message است که به سادگی آن را روی ” (خالی) قرار دهیم، همانطور که در زیر نشان داده شده است:

$password_form_message = 
__( '' );

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

دکمه بازگشت به بالا
x

Array ( [0] => 2024 [1] => آکسیو [2] => https://axio.ir/ )

fa_IR