• Resolved af3

    (@af3)


    I am now able to show random authors using this plugin — thank you!! However, everytime the page is refreshed, the authors would change as expected. How do I make the random authors to change only one a day ? i.e. random authors shown are not changed until the next day.
    Thank you in advance.

    https://wordpress.org/plugins/author-avatars/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Paul Bearne

    (@pbearne)

    OK you will need to a bit of coding for this

    The only why I can thing of doing what you need is:

    call the author avatar shortcode via do_shortcode() and cache the output in a transuent set to expire in 24 hours

    $my_ramdom_avater = get_tranistent(C;
    if( false == $my_ramdom_avater ){
    $my_ramdom_avater = do_shortcode(‘[author_avatar …]’);
    set_tranistent(‘my_ramdom_avater’, $my_ramdom_avater );
    }
    echo $my_ramdom_avater;

    put this in the theme where need it to display
    this hasn’t test at all

    Thread Starter af3

    (@af3)

    Thanks Paul. Checking it out now..

    Thread Starter af3

    (@af3)

    the idea works. thanks again!

    Plugin Author Paul Bearne

    (@pbearne)

    I forgot to set the cache expiry time in the

    set_tranistent(‘my_ramdom_avater’, $my_ramdom_avater, DAY_IN_SECONDS );

    I added the required option to it here

    http://codex.wordpress.org/Easier_Expression_of_Time_Constants

    Thread Starter af3

    (@af3)

    Thanks. I used this to generate 3 random users to win free lunch of the week:

    $random_id = '';
    if ( false === ( $random_id = get_transient( 'free_lunch_avatars' ) ) ) {
    $random_id = do_shortcode('[authoravatars hiddenusers=admin limit=3 order=random avatar_size=120 show_name=true]');
    set_transient('free_lunch_avatars', $random_id, 60*60*24*7); # save the ID returned, transient 7 day
    }
    echo $random_id;

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘show random authors once per day’ is closed to new replies.