How to save a viewer specific option

Is there a standard interface in WordPress for saving a global PHP variable $bgcolor to the user and read it from him anytime he browses to another blog page. There is nothing that will automagically do it for you but it sounds like you just need to save a little bit of user meta, and … Read more

How to set custom cookies in WordPress after a form is filled on a page

Your page-xyz.php has to look like this: $cookie_set = isset( $_COOKIE[‘mycookie’] ); if ( $_SERVER[‘REQUEST_METHOD’] == ‘POST’ ) : // exec your mysql queries and do else stuff… // after it set your cookie setcookie(‘mycookie’, ‘some value’); $cookie_set = true; endif; if ( $cookie_set ) : // render your content here else : // render … Read more

setcookies and header send

The issue you have appears because you set your cookies too late. You have to set it before anything will be rendered. Set your cookies in the your-plugin-file.php file. Also you can check if headers were sent or not by calling headers_sent() function: add_action( ‘init’, ‘wpse8170_init’ ); function wpse8170_init() { if ( !headers_sent() ) { … Read more

Error when setting cookie

You set the cookie too late. You can use any action before template_include to set a cookie, after that there is already HTML output, and no further headers can be set. Example: add_action( ‘template_redirect’, function() { setcookie( ‘test’, 1 ); });

Set cookie for visitor

If you are looking for user only comments then you could try this one ( http://codex.wordpress.org/Function_Reference/wp_set_auth_cookie). This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead. Sets the authentication cookies based User ID. The $remember parameter increases the time that the cookie will be kept. … Read more

Cookie with referral URL [closed]

You can do this as we do in PHP. You can set cookie following way. setcookie( ‘cookie-name’, ‘cookie-value’, ‘cookie-expiration-time’, ‘cookie-path’, ‘cookie-domain’, false ); For referral url, I made following code that you can use to set a cookie with name my-referral-cookie and time() + 3600 (1 hour from current time) is expiration time for cookie. … Read more

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