Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Morgan Kay

    (@gwendydd)

    Where do you want to change the shift title? If you want to change it on the shift detail page, that is fairly simple. If you want to change it on the master schedule and your schedule pages, that’s a little more complicated, but not hard. If you want to automatically change it in the WordPress dashboard, that gets even more complicated.

    Let me know where you want it to change, and I can give you some code to do it.

    Thread Starter lswitzer

    (@lswitzer)

    I’m looking to change the WordPress title. I display a list of the shifts and it would be nice to add the connected employee and assigned date to the titles. Thanks so much!

    Plugin Author Morgan Kay

    (@gwendydd)

    I’m still not quite sure where you want the title to be displayed this way. Actually, part of the question is: do you want the shift title to include the employee and date, or do just want it to be displayed that way in some places? And do you want it to be displayed that way in the master schedule, or just on the shift details page?

    Thread Starter lswitzer

    (@lswitzer)

    To clarify: I just want to change the actual shift title to include the employee name &&/|| the job. The master schedule has all the jobs & employees attached so we’re good there.

    Thanks so much for any help- I’m trying things too.

    Plugin Author Morgan Kay

    (@gwendydd)

    If you want to change the actual shift title, is there any reason not to just type the employee and date into the title field?

    You have two other options for making this happen, and both involve some code. I have no idea what your coding skills are, so I’m going to toss out some general pointers here, but feel free to ask me for more detail.

    Option 1:
    Filter the title. This won’t actually change the title, but it will change how it is displayed on the front end of the site. If you look at the filed called views.php, the first function in that file changes the shift title on the single shift view. You will need to remove that filter with:
    remove_filter( 'the_title', 'wpaesm_single_shift_title', 10, 2 );
    and then write your own filter. You can use that filter as a guide.

    The tricky part here is getting the employee and the date. You can get the date with:
    get_post_meta( '_wpaesm_date', true );
    The employee is connected to the shift using WP Posts 2 Posts. Here are instructions for finding the employee: https://github.com/scribu/wp-posts-to-posts/wiki/Posts-2-Users

    Option 2:
    If you want the title that is saved in the database to include the employee and date, but don’t want to have to enter that in manually, you can hook into the post save action to change the title as the shift gets created. In theory, this sounds pretty easy, but in practice it gets quite complicated, because you have to make sure the shift date and employee are saved before you alter the title. You also have to make sure you only do this when the shift is first created, not when it is edited, so that you don’t end up altering the title every time you save it. For some guidance on how to do this, look in employee-scheduler-pro.php, starting around line 1153. You’ll see a function there called wpaesm_run_that_action_last – that figures out what priority to make the function so that it will run very last thing. The function after that sends a notification to the employee, so you can see from that function how to find the employee and the date. From there, you can update the post title.

    Like I said, if you want more guidance about how to do either of these, don’t hesitate to ask.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Append employee name/date to shift title on create’ is closed to new replies.