How to use current_user_can()?
Probably because the global $current_user isn’t valid yet, which is used by current_user_can(). However, you can use this instead; if ($user->has_cap(‘manage_options’)) { return admin_url(); }
Probably because the global $current_user isn’t valid yet, which is used by current_user_can(). However, you can use this instead; if ($user->has_cap(‘manage_options’)) { return admin_url(); }
Here’s how we do it: $user = get_user_by(’email’, $email); if (wp_check_password($password, $user->user_pass, $user->ID)) { // Login successfull, redirect if needed wp_set_auth_cookie($user->ID); } Assuming of course that you got the $email and the $password variables from a POST request or something 🙂
To be honest? It’s a little bit hard to say… This behavior was introduced in 3.9.2 (which is security release). Here’s the bug in Trac: 29060: Don’t pass around the resetpass key, but there isn’t much info on why was it introduced in the bug report. Is it for security reasons? Most probably. But does … Read more
Here is a pretty simple approach to changing the logo. Mark Jaquith of WordPress released a plugin that allows you to upload an image which will be shown on the login page instead of the WP logo. Customize the WordPress Login Screen Logo
If you will work with sessions, then init this at first in your plugin, theme. add_action( ‘init’, ‘my_start_session’ ); function my_start_session() { if ( session_id() ) return; @session_cache_limiter(‘private, must-revalidate’); //private_no_expire @session_cache_expire(0); @session_start(); } Alternative use the library from Eric Mann: WP Session Manager, also his tutorial.
(side note) In wp-config you can set: define(‘CUSTOM_USER_TABLE’, $table_prefix.’my_users’); define(‘CUSTOM_USER_META_TABLE’, $table_prefix.’my_usermeta’); So I would expect this to work especially for the case when you have centralized your user database… but it does not: http://core.trac.wordpress.org/ticket/13323 (and a username/password for the remote database to get the info from) I think this is the best way to go: … Read more
You can share user tables between different WordPress installations by installing the second site (“Site B”) to use the original site’s (“Site A”) database, then choosing to use an alternate table prefix during installation so as to keep the rest of the data separate. The second part of the problem is sharing login cookies between … Read more
Your only solution (without modifying core files) is to use JavaScript. function wpse_159462_login_form() { echo <<<html <script> document.getElementById( “user_pass” ).autocomplete = “off”; </script> html; } add_action( ‘login_form’, ‘wpse_159462_login_form’ ); Having said that, if you’re not the only one that will be signing in I would advise against disabling autocomplete, it will almost certainly **** people … Read more
Using the [woocommerce_my_account] shortcode, a user will see their account details if they’re logged in and if they’re not logged in, they’ll see a login and registration form. Using the same page title “My Account” for these different users isn’t ideal because a user that has never created an account won’t naturally navigate to a … Read more
WordPress keeps you logged in for 48 hours by default. If you click the “Remember Me” checkbox, it will remember you for 14 days. If you would like to remain logged in for longer than this period of time, you must use the “Auth Cookie Expiration” hook that WordPress provides. Now, you’ve mentioned that you’ve … Read more