PHP setcookie function not being set on wordpress splash page implementation - php

So I'm trying to get a splash page implemented on a wordpress site. I've looked around and read about how to do it using PHP. The idea of the splash page is to redirect people that haven't viewed the site to a splash page that encourages them to donate. The page is already set to a static homepage which I am making the splash page be. Provided here is the code that I have for the cookie, for some reason when I go into my settings on chrome and check to see if the cookie is being written it doesn't show up.
<?php
if((strpos($_SERVER['HTTP_REFERER'], get_bloginfo('home')) === false) && !$_SERVER['QUERY_STRING'] && $_COOKIE["CookieName"] != 'true') :
setcookie("CookieName", 'true', time() + 3600*24*15, "/~user/");
?>
//splash page code
<?php else : ?> //theme code <?php endif; ?>
The else condition is the information for the homepage that was created by the theme. The URL for the site is in the format of siteIP/~user/. If you guys have some feed back that would be greatly appreciated. Also if you can provide a source so that I can read up on it that would also be appreciated. Thanks for your time.

Sorry for posting an answer but I can't comment because I don't have the rep.
Besides reviewing the comments above, try simplifying - check that the if statement is being executed, then you'll know if you have an error in the cookie setting.
Also, your code as quoted doesn't have a closing statement, I assume you have that in the actual page but thought I would mention that.

The reason that it didn't work is because there was a file that was overwriting the splash page itself so the code on the splash page wasn't being called in the first place. It's a matter of just naming files so that it doesn't have any additional files overwriting it the content that you put up there.

Related

whmcs module clientarea page per bought product

so I have 2 modules one working(paid for not encrypted)learned a lot from it lets call this the reference_module and I have my own module which was a PHP page which I am rebuilding for WHMCS and it is almost working completly lets call it created_module.
the problem right now I have is the reference_module is called by when going to https://domainwhmcs.nl/clientarea.php?action=productdetails&id=0001&reference
which is working and shows what I want:
the normal header
normal sidebar
normal footer
and its own content in the main content area
it does this by using hooks having ReferenceClientareaheaderoutput and ReferenceClientareapage which works.
so now I tried to recreate this in created_module but when going to https://domainwhmcs.nl/clientarea.php?action=productdetails&id=0001&created which is working but shows me:
its own content
just its own content but I want the same as in Reference.
I think if I am going to paste the code the post will be to long if needed maybe I can post specific parts.
Allread thanks for helping
so I actualy did solve it today you have to use javascript
jQuery.post("index.php",{"action":'dbinfo',"user":username,"serviceid":serviceid},
function(data){
jQuery(".main-content").html(data);
jQuery("#tabs li").removeClass("active");
jQuery("#tabs li").eq(index).addClass("active");
and
if (isset($_POST['action']) && $_POST['action'] == "dbinfo") {
this you do in your module hook if you need help you can contact me

How can I include / exclude a part of an included PHP file based on the file I am including it in?

The title is a bit convoluted. Let me explain better.
I'm making a blog where registered users can delete and edit their posts. The posts are displayed on 2 sites - the main page, and an admin control panel page. The code for generating the posts is in a separate file.
On the title page, everyone should only be able to see the posts. On the admin page, registered users can edit / delete their posts using the same included php file. There is one function smack in the middle of the code that determines if the editing buttons are visible. I want that function to be present when the file is included on the admin page, and not be present when it is included on the main page.
Let's say that the file which is included, blogposts.php looks something like this:
<?php
code
function();
rest of code
?>
What can i do to exclude that function in the instance where I don't need it?
I've also tried deleting the function and writing:
<?php
require "blogposts.php";
function();
?>
That executes it only on the last post, but should execute it on all of them since it is part of a while loop in the original code.
So, other than writing the code twice, once with and once without the function, if you guys have any ideas I'd appreciate it,
You could place the function inside an if statement, and check the current page against $_SERVER['REQUEST_URI'].
Something like:
if($_SERVER['REQUEST_URI'] == '/current_page_uri.php')
{
function();
}
And then replace the '/current_page_uri.php' with the URI for your admin page.

Stop a particular <div> appearing on just one page

I was wondering could you help me, we currently have an announcement banner across the top of all our webpages which I want to remain apart from one page. A couple of guys did a bit of work for me a put an announcement in which I can edit via Custome Content Type Manager on Wordpress.
In the Header.php the code is there and I'm not sure how to get it to stop appearing on a particular page, the id of the page I DONT want it on is 2664. The code is shown below:
<?php
$gathering_page = get_the_ID();
if( ($gathering_page == 3001 || $gathering_page ==2664) && !(is_front_page()) ){ ?>
I'm not sure if the guys have tried to block it or what this code means.
Any feedback would be appreciated. Thanks
EDIT: This may make it easier; I would like to make a div class disappear on the page named above. the div class is
<div class="snippetHomeTop">
I'm sorry if I did wrong, but have you tried using the is page?
<?php if (is_page('2664')) {
// donĀ“t show content for page ID 2664
} else {
// show content for other pages
}?>
Good Luck

How can i check if there is any content in them main page of joomla?

i am using joomla 3 for a web site, i don't use any content in the main page but the system output is on because i need to output contents on other pages of the site. the problem is i have a space in the middle of the page where normally the content comes. i know where this comes from but i have to disable it if there is no content on that selected page. i tried to check the
$this['template']->render('content')
which is actually used to render the specific content. but i was not able to use it in a conditional if. so i need to check if the loaded page has a content output. has anybody a idea how i could do that?
PS: i dont want do this with css.
You may check if you are showing the main page and render conditionally:
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
$this['template']->render('content');
}
?>
For multilingual site check this link for detecting if you are on the default page:
http://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page
Just curious... why don't use the <jdoc:type="component/>?

How can add tracking code (tradetracker and daisycon) on thank you page

I have a task, I did research but I still cannot be done.
I am using OpenCart. And I have to add code tracking (from tradetracker and daisycon) to thank you page.
How can I do it?
If you aren't too comfortable with writing your own extension and your tracking code is JavaScript or HTML you can place it straight into your template. You will find the template you need in:
/catalog/view/theme/default/template/common/success.php
The only problem is that this will now fire every time the page loads. Any success goes to this template.
To fix this you need to go into the controller and make a small addition.
Find:
if (isset($this->session->data['order_id'])) {
Add a new line below reading:
$this->data['enable_tracking'] = TRUE;
Then back in the template before simply add an if statement round the tracking code you have added like so:
<?php if($enable_tracking === TRUE){ ?>
Delete this line and replace with tracking code
<?php } ?>
That should solve your problem.

Categories