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't access Gravity Forms table?

  1. Hi guys,

    I've been working on this for the past 4 hours and I'm ready to pull my hair out. ;)

    All I'm trying to do is display some of the values in the Gravity Forms custom table. But no matter what parameters I adjust, I can't get it to show anything. At the same time, I can pull and display data from the WordPress default tables with a problem (e.g. wp_users, wp_links, wp_comments, etc.)

    Below is the code I'm fighting with:

    <?php
    	function show_signers() {
    		global $wpdb;
    		$mylink = $wpdb->get_row("SELECT * FROM $wpdb->rg_lead_detail WHERE id = 117");
    		echo "The ID is: " . $mylink->form_id;
    	}
    	show_signers();
    ?>

    But all that shows up are the words "The ID is: ". I've verified that values <b>do</b> exist in the Gravity Forms table that I'm trying to access.

    So... what am I doing wrong?

    Thanks!

    Posted 12 years ago on Wednesday September 21, 2011 | Permalink
  2. If you dump the array $mylink, what's in it?

    Where does this code live? Is it in a template file?

    Posted 12 years ago on Wednesday September 21, 2011 | Permalink
  3. Yeah, it's just an everyday template file for a regular old page. If I use the virtually identical code below that queries a WordPress default table it works.

    <?php
        function show_signers() {
            global $wpdb;
            $mylink = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = 116");
    		echo "The Title is: " . $mylink->post_title;
        }
        show_signers();
    
    ?>

    Any thoughts? Do you have any examples of code that work for you?

    Posted 12 years ago on Thursday September 22, 2011 | Permalink
  4. Btw, I had the Gravity Forms Directory & Addons plugin activated. I thought that perhaps it was conflicting so I deactivated it but it hasn't made a difference.

    Posted 12 years ago on Thursday September 22, 2011 | Permalink
  5. Oh, and I dumped $mylink using var_dump($mylink); and it returned "NULL".

    Posted 12 years ago on Thursday September 22, 2011 | Permalink
  6. Try this as line 4 of your code (the line after global $wpdb;)

    [php]
        $wpdb->rg_lead_detail = $wpdb->prefix . 'rg_lead_detail';

    The query works fine for the posts table since that is defined as part of the wpdb object already. I think you have to define rg_lead_detail yourself.

    It worked for me.

    Posted 12 years ago on Thursday September 22, 2011 | Permalink
  7. Wow! That worked. Fabulous!

    Posted 12 years ago on Thursday September 22, 2011 | Permalink
  8. Great. Glad that worked out for you.

    Posted 12 years ago on Saturday September 24, 2011 | Permalink

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