Appropriate WP hook to use set PHP cookie
Appropriate WP hook to use set PHP cookie
Appropriate WP hook to use set PHP cookie
Putting the code below in the settings.php file to boycott cookies solved my issue. define( ‘AUTH_KEY’, ‘put your unique phrase here’ ); define( ‘SECURE_AUTH_KEY’, ‘put your unique phrase here’ ); define( ‘LOGGED_IN_KEY’, ‘put your unique phrase here’ ); define( ‘NONCE_KEY’, ‘put your unique phrase here’ ); define( ‘AUTH_SALT’, ‘put your unique phrase here’ ); define( … Read more
Need help for deleting a WordPress Cookie with setcookie() Not Working
Allow file access only via cookie
You can set the cookies on the two different pages by modifying your code to include the logic for setting the cookies when a user clicks on one of the options. Here’s the updated code: function my_page_template_redirect() { if ( isset( $_COOKIE[“landvanbartje_cookie”] ) ) { if( $_COOKIE[“landvanbartje_cookie”] == “buiten_seizoen” ) { wp_redirect( ‘/omgeving-rust-ruimte/’ ); exit; … Read more
Multisite logged into one wp-admin, move to another sites wp-admin asked to login again
I found that I need a must-use plugin. First I created a folder: wp-content/mu-plugins. Next I added the following code: error_log(‘plugin filtering’); add_filter(‘option_active_plugins’, function (array $plugins){ error_log(json_encode($plugins)); return $plugins; }); It lists all my plugins before they are loaded. So I can use a cookie to store user consent for different plugins and use this … Read more
Can’t set a cookie from php
Since you are relying on the URL parameter to set cookies, why not prioritize it over the cookie for the first page load? At your second code block, changing the line $plan_cookie to this might help. $plan_cookie = isset($_GET[‘plan’]) && !empty($_GET[‘plan’]) ? $_GET[‘plan’] : (isset($_COOKIE[‘plan’]) ? sanitize_text_field($_COOKIE[‘plan’]) : ”);
Found two solutions: 1) global $current_user; $wp_get_current_user_id = $current_user->ID; $wp_get_current_user_id = apply_filters( ‘determine_current_user’, false ); Which then in helloworld.php would be return: echo json_encode( array(‘wordpress_user_id’ => wp_get_current_user_id) );