It depends on where your login script is. This is my testscript (saved as ìndex.php`):
<html>
<head>
<title>Testform</title>
</head>
<body>
<?php
require_once '../wp-load.php';
var_dump($_COOKIE);
if ( !( current_user_can('level_0') ) ){
wp_login_form();
}
else { ?>
<ul>
<li><a href="https://wordpress.stackexchange.com/questions/58764/<?php echo home_url("/wp-admin/'); ?>">Admin</a></li>
<li><a href="<?php echo wp_logout_url( get_permalink() ); ?>">Logout</a></li>
</ul>
<?php } ?>
</body>
I installed WordPress in a subdirectory on my local server (testdoma.in/wordpress
). If I install the script in a subdirectory within my WordPress installation (testdoma.in/wordpress/external
), it works. If I install the script in the root (and change the require_once
to wordpress/wp-load.php
), no way to get it working.
If you try to access WordPress functions, the scripts have to be in a subfolder of or directly within your WordPress installation.
UPDATE
After some research, it is a cookie problem. The plugin root Cookie will resolve the problem.