PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Can I make update wp_postmeta early?...

  1. Hi There.

    I may need to tweak Gravity Forms a touch to make an insert into wp_postmeta occur before a plugin activates. I'll explain...

    We have a site which creates custom posts using Gravity Forms.

    Using BuddyPress Group Subscription, users are able to sign up to groups & recieve these posts via email.
    Using BuddyPress Group Subscription, users can choose a digest of posts or see all posts.

    The users need to be able to read the entire post when All Email is selected.

    Under normal circumstances, user hits the Submit button on our Gravity Form, the post is then added to the activity stream, & the email content is sent out.

    Normally, when the addition is made to the Activity Stream, the post_title & post_content is used, all located in wp_posts.

    I have written a function that pulls the relevant data from wp_posts & wp_postmeta to return a string that contains all the information required.

    The problem is that, when the post is added to the Activity Stream at that point wp_post contains the correct data, but wp_postmeta does not have the custom form data added yet.

    I tested this by decrementing the post_id by 1 when my function was called ( which is called 1 line prior to adding the post to activity stream) & the function works perfectly.

    So in an nutshell what's happening is:

    1) User presses submit
    2) data is inserted into wp_posts
    3) data is added to Activity Stream - (Data for the email functionality)
    4) data is added to wp_postmeta

    Is there a way I can make Gravity Forms do 4) before the Group Email Subscription Plugin does 3)?

    Alternatively, is there a way I can make Gravity Forms complete its inserts before another plugin /function even starts? I'd rather take a performance hit of a few seconds on the Email side so that Gravity Forms can work.

    All advice would be appreciated!

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  2. Update: It has been suggested that the reason this is happening is because Buddypress and its associated plugins are occurring before Gravity Forms, as Wordpress stores the list of plugins alphabetically.

    Therefore if I rename the Gravity Forms plugin to AA-Gravity Forms or something similar, all will be well.

    I realise that this will probably break any update notifications for Gravity Forms.

    If anyone has a more elegant solution than this (not tried it yet) any advice would be appreciated.

    Posted 11 years ago on Thursday March 7, 2013 | Permalink
  3. The following page (http://wordpress.org/support/topic/how-to-change-plugins-load-order) allowed me to add functionality to move Gravity Forms to the top of the array active_plugins.

    This saves having to rename the plugin at least.

    However, that didn't help. :(

    Does anyone know what php file is called when someone hits the "Submit" button on a Gravity Form? Perhaps I can add some functionality at that point?

    Posted 11 years ago on Thursday March 7, 2013 | Permalink
  4. I have written a function that pulls the relevant data from wp_posts & wp_postmeta to return a string that contains all the information required.

    What action do you have your function hooked to, and what are you doing with the data you retrieve? Is this related to BuddyPress Group Subscription (and is that a plugin or BP core function)?

    Posted 11 years ago on Tuesday March 12, 2013 | Permalink