Redirect user if it’s not logged in

I wouldn’t use htaccess for that. What I would do is make a ‘download page’ template and use it to ‘serve’ the files. By doing that, I can do a check with is_user_logged_in() Codex and redirect with wp_login_url() Codex Just do: if ( is_user_logged_in() ) : //file link else : wp_login_url(); endif; I think it’s … Read more

Using “wordpress_logged_in” to restrict direct access to uploads folder in 2021

Check to see if a person is logged in: <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} (.*) RewriteCond %{HTTP_COOKIE} !wordpress_logged_in_([a-zA-Z0-9_]*) [NC] RewriteRule .* – [F,L] </IfModule> The same applies as it did 10 years ago. This code in .htaccess doesn’t have anything to do with how WordPress might be setting cookies. And this does not “check to see … Read more

$_POST empty on submit (same code, same form submits normally on local server)

The best way to deal with Form Posts in WordPress is to use a special endpoint, /wp-admin/admin-post.php. POST data can be messed up, both by the WP Query call, and by any redirects that happen. So you set up your form with this action: <form action=”<?= admin_url(‘admin-post.php’) ?>” method=”post”> <input type=”hidden” name=”action” value=”special_action”> <?php wp_nonce_field(‘special_action_nonce’, … Read more

What is the role of .htaccess file in WordPress?

The .htaccess file is not actually required for WordPress to “work”. However, it is required if you wish to create a more user-friendly URL structure (ie. anything other than “plain” permalinks, as Jack suggests). This is also why the default WordPress .htaccess file surrounds the directives in an <IfModule mod_rewrite.c> container. It “works” if “mod_rewrite” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)