How do I use add_action from a class method?
Have you tried add_action( ‘init’, array( $this, ‘auto_sign_in’) ); __CLASS__ returns the class name, not the class instance, so it only works for static functions.
Have you tried add_action( ‘init’, array( $this, ‘auto_sign_in’) ); __CLASS__ returns the class name, not the class instance, so it only works for static functions.
Don’t know if this is the best way, but I’ve been using this in functions.php in my themes: function keep_me_logged_in_for_1_year( $expirein ) { return 31556926; // 1 year in seconds } add_filter( ‘auth_cookie_expiration’, ‘keep_me_logged_in_for_1_year’ );
Write this into a plugin: add_action( ‘template_redirect’, ‘auth_redirect’ ); As plugin on GitHub. This will force all visitors login if they aren’t already. In some cases, this is asking for a log-in every time. This might work better: is_admin() || add_action( ‘template_redirect’, function() { if ( ! is_user_logged_in() ) auth_redirect(); }); If you want to … Read more
There are a few things you can try. One of them you have already tried. Clear your browser cache (which you have stated you have tried), just make sure you cleared everything, cookies and cache. Try deactivating all plugins by either logging in via SSH or FTP to your server and rename wp-content/plugins to wp-content/plugins_backup. … Read more
You can create custom usermeta for has_logged_in or something like that and then check it when the user logs in to see if it exists and is properly set. If so, no email sent, otherwise, email sent. You could take the opposite approach and create usermeta for not_has_logged_in or something like that and then check … Read more
This is not surprising or uncommon, it’s how browsers work, the pages are cached and are part of the browser history. This is not specific to WordPress but many web applications out there. There are also different approaches to providing a solution. For one (not very good solution), clearing the browser history. For another – … Read more
There are a couple of ways to do this. The most simple is probably to install a plugin, such as Theme My Login. The more complicated but flexible way to do it is to use wp_login_form() to output the form, presumably to a shortcode or something, and then you can style it yourself.
You could create a dummy user (with no rights) and log in every visitor using this dummy user. This could be done pretty easily: wp_set_auth_cookie($uid, true); wp_set_current_user($uid); But in my opinion that’s a rather flawy workaround. Your main problem is that all pages for not-logged-in users come from the page-cache. That also means that all … Read more
This message is not part of the WordPress core. I confirmed this suspicion by searching for the message within the WordPress core files. When it was not found, I then searched the message using a search engine. It appears that you are using the New User Approve Message plugin. This message is defined in new-user-approve/includes/messages.php#L33 … Read more
Using wp_deregister_style( ‘login’ ) to remove the login styles will still result in a 404’d request for the login CSS file. However, if you re-register the login style after deregistering it you can prevent the unwanted request. add_action( ‘login_init’, function() { wp_deregister_style( ‘login’ ); wp_register_style( ‘login’ ); } ); This will leave you with a … Read more