admin管理员组

文章数量:1122832

im trying to secure PDF link when I share the link with someone, below is my functions.php code,

function register_download_brochure_menu() {
    add_menu_page(
        'Download Brochure',
        'Download Brochure',
        'manage_options',
        'download-brochure',
        'display_download_brochure_page',
        'dashicons-download', // Icon
        25 // Position
    );
}
add_action('admin_menu', 'register_download_brochure_menu');

function display_download_brochure_page() {
    ?>
    <div class="wrap">
        <h1>Download Brochure</h1>
        <form method="get" action="<?php echo home_url('/wp-content/uploads/2024/07/My-LetterPad.pdf'); ?>" target="_blank">
            <button type="submit" class="button button-primary">Download Brochure</button>
        </form>
    </div>
    <?php
}

function enqueue_admin_styles() {
    wp_enqueue_style('admin-styles', get_template_directory_uri() . '/admin-styles.css');
}
add_action('admin_enqueue_scripts', 'enqueue_admin_styles');

above is my code that display button Download Brochure, and when i click on that button, its open new link, http://localhost/my-project/wp-content/uploads/2024/07/My-LetterPad.pdf, now i copy this link and shared with another user, but here i want, if another user can paste this link in browser, then first its ask for login and then display the pdf URL,

本文标签: urlsHow to secure PDF link when share link to someone