Set cookie using GET variable

Just check if the variable is set, using the code from your link: add_action( ‘init’, ‘set_agent_cookie’ ); function set_agent_cookie() { if (isset($_GET[‘code’])) { $name=”agent”; $id = $_GET[‘code’]; setcookie( $name, $id, time() + 3600, “https://wordpress.stackexchange.com/”, COOKIE_DOMAIN ); } }

Passing Additional Parameters to add_filter Callable

The second parameter in add_filter is a function with accepted arguments, not returned values. This is an example how I pass my custom array $args to change an existing array $filter_args: add_filter( ‘woocommerce_dropdown_variation_attribute_options_args’, function( $filter_args ) use ( $args ) { return eswc_var_dropdown_args( $filter_args, $args ); } ); function eswc_var_dropdown_args( $filter_args, $args ) { $filter_args[‘show_option_none’] … Read more

Why does it say: ‘Cookies are blocked or not supported’?

When you log in to the admin WordPress sets cookies (in PHP) to keep you logged in while you navigate around your site. If this fails, you get the error message, “Cookies are blocked or not supported by your browser.” This could fail in a couple different ways, but before we dig into those situations, … Read more

What is the purpose of having a token in cookies?

According to the WP_Session_Tokens class documentation, this token is used to validate the user’s session. It does this by checking the provided token against the existing session tokens stored in the user meta table for that user. Session tokens are generated using the wp_generate_password function, and are 43 characters long. So no, it should not … Read more

How to mark articles as read?

For a truly full solution you need to have all the users to have an account (or create one when marking as read) and you associate in the DB the user with the posts that he read and then style each link appropriately. To implement this you can look for inspiration in plugins that add … Read more

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