Jump to content

xoibsurferx

New Members
  • Posts

    5
  • Joined

  • Last visited

xoibsurferx's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello everyone, I'm a junior level developer that went through a boot camp to learn Ruby on Rails and have been trying to get hired since but have noticed a lot of php jobs and while I have a basic understanding of php I want to learn more and there doesn't seem to be a lot of free resources that have video tutorials and teach php in depth. I'm not sure if this is the correct place to ask but if there's any free resources you could recommend I would greatly appreciate it!
  2. Thanks for checking this out for me! That definitely makes sense.
  3. Thank you for helping me! That makes sense and I can see how that would help. Newbie question but as you can see there's that IF statement at the beginning for 5min as well as the 30minute one under it. From my understand and I could be wrong but that 5min one is still running as well as the 30min one. Would that also be an issue?
  4. I'm sorry I didn't see an area where I could place the code but I see the <> in the text input tools now. As for more specifics the server we have this app on also has other high traffic sites on it as well. The hosting company has told us that we're exceeding our memory limit and its due to this one app with the code I posted above. Its hosted at liquid web on an apache server. function my_cron_schedules($schedules){ if(!isset($schedules["5min"])){ $schedules["5min"] = array( 'interval' => 5*60, 'display' => __('Once every 5 minutes')); } if(!isset($schedules["30min"])){ $schedules["30min"] = array( 'interval' => 30*60, 'display' => __('Once every 30 minutes')); } return $schedules; } add_filter('cron_schedules','my_cron_schedules'); add_action('thirty_minute_event', 'update_team_avg_points'); function my_activation() { if ( !wp_next_scheduled( 'thirty_minute_event' ) ) { wp_schedule_event( current_time( 'timestamp' ), '30min', 'thirty_minute_event'); } } add_action('wp', 'my_activation'); function update_team_avg_points() { // THIS UPDATES TOTAL USER POINTS. $users = get_users(array( 'blog_id' => 1, )); foreach($users as $user){ $userPoints = get_all_points_for_user($user->ID); update_user_meta($user->ID, '_ecfit_user_points', $userPoints); } // THIS UPDATES TEAM AVG POINT VALUE. $staff_teams = ecfit_get_teams( 'staff' ); $apprentice_teams = ecfit_get_teams( '2k2/Contractor/Intern' ); $family_teams = ecfit_get_teams( 'family' ); if($staff_teams){ foreach( $staff_teams as $team ){ $team_points = $team->get_average_points(); $teamId = $team->get_id(); update_post_meta($teamId, '_ecfit_team_avg', $team_points); } } if($apprentice_teams){ foreach( $apprentice_teams as $team ){ $team_points = $team->get_average_points(); $teamId = $team->get_id(); update_post_meta($teamId, '_ecfit_team_avg', $team_points); } } if($family_teams){ foreach( $family_teams as $team ){ $team_points = $team->get_average_points(); $teamId = $team->get_id(); update_post_meta($teamId, '_ecfit_team_avg', $team_points); } } } I noticed that the edit post feature is missing for the original post above so I would just edit the code there but can't since I must not have permission set to edit posts.
  5. Hello everyone, I'm working on a project that is within a custom wordpress site/app that is using too much memory. Its a fitness app that tracks staff and teams fitness points/scores. I'm 99% sure the cron job is the issue but not quite sure what's off about it causing this app to use so much memory. There are roughly 300 people using this app and they do at least one exercise per day and input it within their profile. Below is the code for the cron job. Is there anything wrong with this code that would cause this app to use so much memory? As you can see its been modified from every 5 mins to every 30 so it doesn't use so much. function my_cron_schedules($schedules){ if(!isset($schedules["5min"])){ $schedules["5min"] = array( 'interval' => 5*60, 'display' => __('Once every 5 minutes')); } if(!isset($schedules["30min"])){ $schedules["30min"] = array( 'interval' => 30*60, 'display' => __('Once every 30 minutes')); } return $schedules; } add_filter('cron_schedules','my_cron_schedules'); add_action('thirty_minute_event', 'update_team_avg_points'); function my_activation() { if ( !wp_next_scheduled( 'thirty_minute_event' ) ) { wp_schedule_event( current_time( 'timestamp' ), '30min', 'thirty_minute_event'); } } add_action('wp', 'my_activation'); function update_team_avg_points() { // THIS UPDATES TOTAL USER POINTS. $users = get_users(array( 'blog_id' => 1, )); foreach($users as $user){ $userPoints = get_all_points_for_user($user->ID); update_user_meta($user->ID, '_ecfit_user_points', $userPoints); } // THIS UPDATES TEAM AVG POINT VALUE. $staff_teams = ecfit_get_teams( 'staff' ); $apprentice_teams = ecfit_get_teams( '2k2/Contractor/Intern' ); $family_teams = ecfit_get_teams( 'family' ); if($staff_teams){ foreach( $staff_teams as $team ){ $team_points = $team->get_average_points(); $teamId = $team->get_id(); update_post_meta($teamId, '_ecfit_team_avg', $team_points); } } if($apprentice_teams){ foreach( $apprentice_teams as $team ){ $team_points = $team->get_average_points(); $teamId = $team->get_id(); update_post_meta($teamId, '_ecfit_team_avg', $team_points); } } if($family_teams){ foreach( $family_teams as $team ){ $team_points = $team->get_average_points(); $teamId = $team->get_id(); update_post_meta($teamId, '_ecfit_team_avg', $team_points); } } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.