Jump to content


Photo
- - - - -
Resolved

Action Hook For When A Custom Section Is Updated

action hooks section updates

This topic has been archived. This means that you cannot reply to this topic.
12 replies to this topic

#1 infogroupsmb

infogroupsmb

    Advanced Member

  • Members

  • 37 posts

Posted 22 October 2012 - 09:48 PM

I am attempting to write a custom function to send the header and footer areas of the the pages to a .net web service anytime the content of the header or footer area is updated. I have worked out the WordPress action hook for when the menus are updated,

Please Login or Register to see this Hidden Content

, but I need to also call my function when the header or footer sections are updated via pagelines. We have custom sections that are being used for the header and footer areas.

I have looked through the Action hooks here:

Please Login or Register to see this Hidden Content


and watched the hook tutorial here:

Please Login or Register to see this Hidden Content



The video is talking more about Filters than Actions (using WordPress terminology) and the list of Actions in the api page doesn't show anything that might relate to updating a specific section.

So I have 2 questions:

1. Is there a pre-exisiting Action hook for when a custom section's site wide settings are updated such as through PageLines > Page Options and selecting the section?

2. If not, how can a custom Action hook be added to a section's update?

#2 James B

James B

    Advocate

  • Members

  • 5126 posts

Posted 23 October 2012 - 04:43 AM

Hi there, I honestly don't know the answer on that one, but I will forward your request on to one of our developers and either myself or someone on the team will get back to you shortly to advise further.

#3 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts

Posted 23 October 2012 - 11:27 AM

Wordpress has a built in action hook for any option saved to the database, so you can use option_pagelines-settings-two

#4 infogroupsmb

infogroupsmb

    Advanced Member

  • Members

  • 37 posts

Posted 23 October 2012 - 04:26 PM

If I understand you correctly Simon_P option_pagelines-settings-two will trigger when any option is saved. Is there a way to add an action hook to a specific custom pagelines section? Otherwise option_pagelines-settings-two will be triggering all the time and I only want to do all the processing and call the web service when the menus, custom header section or custom footer section are updated.

#5 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts

Posted 23 October 2012 - 04:34 PM

Oh right, well in that case you could the ploption filter....

so if the option is footer_text for example, filter will be ploption_footer_text

Its a filter so you MUST pass the option back. You can see it in use here

Please Login or Register to see this Hidden Content



#6 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts

Posted 23 October 2012 - 04:51 PM

Actually thats not gonna work...

This is how id suggest you do it...

First add an action that hooks into the option_pagelines-special option...when its triggered it can copy the settings you are monitoring to a temp setting. The the next time it is triggered, it can compare the saved 'new' setting with your temp setting ( the old one ), if they are different then fire your API calls.

#7 infogroupsmb

infogroupsmb

    Advanced Member

  • Members

  • 37 posts

Posted 23 October 2012 - 07:50 PM

We don't really care that much if the actual value of the option is being changes, just that someone has updated it. Also, it's not necessary to trigger this when someone makes a page specific change, but only when they update the site default options through pagelines > page options > site defaults.

#8 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts

Posted 23 October 2012 - 08:40 PM

In that case just use the option_pagelines-special option action

#9 infogroupsmb

infogroupsmb

    Advanced Member

  • Members

  • 37 posts

Posted 29 October 2012 - 08:03 PM

May I ask for an example? For instance in order to call my updater function when a WP menu is changed I use

Please Login or Register to see this Hidden Content


So to trigger the same function when the the page options for the custom header and footer sections are updated I'd use

Please Login or Register to see this Hidden Content

?

And if that is correct, how does it know to only trigger when specific page options are changed, i.e. the header and footer options? I was assuming I'd have to add some custom hook to those 2 sections.

#10 infogroupsmb

infogroupsmb

    Advanced Member

  • Members

  • 37 posts

Posted 01 November 2012 - 06:21 PM

Ok so

Please Login or Register to see this Hidden Content

seems to trigger any time someone navigates to any page options page, not just when an update occurs.
and
it seems to trigger every time a ploption is pulled to populate the page options page which means it is calls WAY too many times (and has even caused the script to timeout now)

#11 infogroupsmb

infogroupsmb

    Advanced Member

  • Members

  • 37 posts

Posted 02 November 2012 - 06:11 PM

Simon, though

Please Login or Register to see this Hidden Content

didn't work your suggestion lead me in the right direction. The hook I ended up using is

Please Login or Register to see this Hidden Content

Thanks for pointing me in the right direction :D

#12 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts

Posted 02 November 2012 - 09:41 PM

I'm very happy you were able to resolve this. Well done!

#13 Jenny

Jenny

    Advocate

  • Unicorn Store Dev

  • 2924 posts

Posted 05 November 2012 - 06:33 PM

The topic was marked as resolved.