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.

Conditional statement to check game status and week using database in Wordpress

  1. I have a request where I want to use a conditional statement which checks if the user's team is playing home or away for that week, this data is stored in a custom database in WordPress, and then display a form according to the result.

    For example: team a is playing home this week, so the result would show the users team name and and display the status of the game to be either home or away (based on which date the query was ran) this would then re-direct the user to the correct form to choose their players for that game.

    I believe a hook and filter is required to perform this function? But how do I query the database, I have seen similar queries for WP posts but not for a custom database table?

    My problem is that little knowledge of PHP, hence have used conditional logic using check boxes for the time being.

    Posted 12 years ago on Thursday October 25, 2012 | Permalink
  2. Querying the database is outside the realm of support we can give for Gravity Forms. However, here is a general approach to querying a custom MySQL database table http://pastebin.com/8BxAPgka

    That is part of code which matched up an input account ID with an email address which was stored in the database. You won't need most of that, but the connection details and how to perform the query and how to return and loop through the results should be helpful.

    Let us know when you get stuck. Thank you.

    Posted 12 years ago on Thursday October 25, 2012 | Permalink
  3. Where do you put that code from your pastebin.com link? Is it added to the functions.php or a specific gravity forms code? How do you connect it to the gravity form?

    Posted 11 years ago on Wednesday February 13, 2013 | Permalink
  4. That code is added to your theme's functions.php file.

    http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F#PHP

    This filter:

    gform_notification_email_28

    Will run at the proper time to change the notification email, for form 28. That is the reason for the _28 on the end.

    If you need more specific assistance, please open a new topic and we'll address your questions there.

    Posted 11 years ago on Sunday February 17, 2013 | Permalink

This topic has been resolved and has been closed to new replies.