homepage Welcome to WebmasterWorld Guest from 54.226.136.179
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Can't find my error in PHP being written for Wordpress
I need a timed event to occur after a page is loaded
calvinmicklefinger

5+ Year Member



 
Msg#: 4636590 posted 9:41 pm on Jan 10, 2014 (gmt 0)

I want an event to happen a short time after a wordpress page is loaded.

My function is in the custom page template.

In the code, I am using the time the page is loaded as part of the function name in case multiple instances of the page are opened.

(1) My page is not loading, which indicates to me that the code I am using is wrong, and

(2) I am wondering if this method will even work for what I want to do, which is to cause a message to be echo'd on screen after the visitor has been on the page for 60 seconds.

Any ideas on my code error, and any thoughts on a better method?

Many thanks!
CM

 

calvinmicklefinger

5+ Year Member



 
Msg#: 4636590 posted 9:42 pm on Jan 10, 2014 (gmt 0)

Forgot to insert the code, and missed the edit button until I had posted this reply.

Here's the code.


<?php
$type = timestamp;
$time = current_time( $type, $gmt = 0 );
$timestamp = $time + 60 ;

function my_timed_function_$time(){ echo '<h1>POPUP</h1>'; // Do something. Anything.}

add_action('my_timed_action','my_timed_function_"<?php $time ?>"');
wp_schedule_single_event($timestamp,'my_timed_action');
?>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved