0

I am new to PHP and coding and I am really not a coder but I try to modify and use existing codes.

I have a function which I am trying to run when needed for all users within Wordpress to do an action for each user (if needed). I have a script that looks like this:

<ul>
<?php
    $allusers = get_users();
    foreach ($allusers as $user) {
        do_action('active_campaign_users_update', $user->ID);
    }
?>
</ul>

I have placed this withing a page template to call the private page to update the field only when needed for all the users. The problem is, the script time outs of course and I expect the user database to increase significantly once I launch my website.

Therefore, I was looking into possible approaches to modify the function to run in patches and reload the page to continue from where it left off. I would also love to know any suggestions as to how best to achieve this. For instance, some other similar topics on the internet suggested to use a cron script for this. However, I am not really a competent coder and don't yet have an understanding if that is the best solution and how to go ahead to run a cron script within Wordpress.

If it is relevant, my host is WP Engine.

Thanks a lot for your time and I look forward to your suggestions!

  • What do you have hooked to that action? I very much doubt that that code alone will cause a problem, but the callback could. – s_ha_dum Dec 8 '13 at 18:54
  • I'm not sure I full understand what you are trying to do. I'd probably put the foreach loop in the callback, but that's just me and probably wouldn't have much effect. – helgatheviking Dec 8 '13 at 20:14
  • The action is for a plugin that pushes users' meta-fields to an external e-mail marketing service. So, it runs the action for each user to update their information on the external service. – Dr.Hariri Dec 8 '13 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.