Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter J B

    (@kreuzian)

    oops I saw one of my own errors in the code but the problem remains. are you suggesting I have to use codeigniter with wordpress? isn’t it a seperate platform?

    How can I achieve this in wordpress without codeigniter. The cookiehelper doesn’t work.

    Thread Starter J B

    (@kreuzian)

    This is a code I wrote to test it to say “hello”, but it says:
    Fatal error: Call to undefined function get_cookie()

    <?php if (!get_cookie('new_visitor')) {?> hello <?php } ?>
    // cookie not set, first visit
    
    // create cookie to avoid hitting this case again
    $cookie = array(
    'name' => 'new_visitor',
    'value' => 'Yes',
    'expire' => time()+86500,
    'domain' => 'mysite.com',
    'path' => '/',
    'prefix' => '',
    );
    set_cookie($cookie);
    }
        ?>

    How can I fix it?

    Thread Starter J B

    (@kreuzian)

    Basically if I put my code I only want to activate once, like my welcome message, in the spot mentioned above it would work only once, and then the cookie is planted right? and since it is activated only if it can NOT get_cookie then it wouldn’t activate again right?

    just checking. thanks again.

    Thread Starter J B

    (@kreuzian)

    Not sure what to do. Correct me if I’m wrong.

    if (!get_cookie(‘new_visitor’)) { —INSERTING code here would work BEFORE cookie planted??—-
    // cookie not set, first visit

    // create cookie to avoid hitting this case again
    $cookie = array(
    ‘name’ => ‘new_visitor’,
    ‘value’ => ‘Yes’,
    ‘expire’ => time()+86500,
    ‘domain’ => ‘.my-domain.com’,
    ‘path’ => ‘/’,
    ‘prefix’ => ”,
    );
    set_cookie($cookie);
    }

    Thanks for the help.

    Thread Starter J B

    (@kreuzian)

    You are my hero! Seriously. Thanks a million. Problem finally solved.

    Thread Starter J B

    (@kreuzian)

    The goal is that every user who sees Page A sees one quote,
    And every user who sees Page B sees a different quote.

    Thus randomized, but not changing (neither on refresh or per user).
    Any ideas?

    Thread Starter J B

    (@kreuzian)

    I found one solution, by adding
    srand(floor(time() / (60*60*24)));
    before the rand it stays the same for 24 hours for example (and I guess I can set it to a super high time to avoid repeating).

    HOWEVER, if put in the sidebar or header it outputs the same result for ALL pages. Is there any way I can put it in the header and have it show a different result for EACH page? I suspect I will need to use wordpress code for it (adding it into the loop).

    Thread Starter J B

    (@kreuzian)

    I have no idea how I would modify that or how it works.

    I thought there might be some wordpress related solution or php solution such as the one below

    <?
     //Chooses a random number
     $num = Rand (1,6);
     //Based on the random number, gives a quote
     switch ($num)
     {
     case 1:
     echo "Time is money";
     break;
     case 2:
     echo "An apple a day keeps the doctor away";
     break;
     case 3:
     echo "Elmo loves dorthy";
     break;
     case 4:
     echo "Off to see the wizard";
     break;
     case 5:
     echo "Tomorrow is another day";
     break;
     case 6:
     echo "PHP is cool!";
     }
     ?>

    But it always changes on refresh. I want it to NOT change on refresh. Is this possible?

    Thread Starter J B

    (@kreuzian)

    Oh nevermind, I got it working.

    Thread Starter J B

    (@kreuzian)

    So how would I use that?

    If I put, for example:

    <?php
    $author = get_query_var(‘author’);
    if ($author = ‘admin’) {
    echo ‘hello’;
    }
    ?>

    It says hello on all posts not just the admin’s. How can I make it specifically show that hello (or whatever code I want) on ONLY those posts done by a specific author?

    Thread Starter J B

    (@kreuzian)

    Why doesn’t that code work? What code would work?

    I keep trying variations and different things with no success. All I want is to be able to have a string check who is the author of a post, and if it is Joe, then display Joe’s image on all of Joe’s posts, and if it is Sally, Sally’s image on all of Sally’s posts.

    Is this impossible with wordpress? Why? Is there a way to create a variable specific to each author? That would allow me to accomplish this.

    Thread Starter J B

    (@kreuzian)

    NO, NO, NO, you misunderstand!!! Didn’t you read what my goal is??

    I don’t want it to just display their name (as “the_author”) does. I don’t want it to “check” if there IS an author.

    What I want is for it to check WHO IS the author, and if it is Joe, for example, then it would display “Joe’s image” in the header. If it is Sally, then Sally’s image. Simple enough.

    <?php if ($post_author = ‘admin’) {
    echo ‘joes image here’;
    }
    ?>

    Problem is it doesn’t appear at all in the header.php with that code, and if it’s on the single.php it always appears regardless of the author. I just want to fix that please.

    Thread Starter J B

    (@kreuzian)

    Well that’s weird, I tried that but it didn’t work.

    <?php if (is_author(‘admin’) ) {
    echo ‘hello’;
    }
    ?>

    I put that in the template, in header.php and even in the posts themselves with single.php and “hello” didn’t show up in either. What am I doing wrong? I get the author part now I think, but can you give me the full code? Or does it not work with WordPress MU? Thanks for your time.

Viewing 13 replies - 1 through 13 (of 13 total)