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.

Get entry object by user ID

  1. I have quick question that I hope you can help with.

    I need to get an entry object by user ID. The form can only be submitted by logged-in users, so the $entry['created_by'] field is set. I just need to know how to pull the entry from the database using that user's ID.

    I couldn't find anything in the developer docs, but I might be looking in the wrong place.

    Posted 12 years ago on Tuesday June 28, 2011 | Permalink
  2. Justin,
    To query the entry data using the created_by field, you can use the following SQL statement.

    [sql]
    SELECT l.*, field_number, value
    FROM wp_rg_lead l
    INNER JOIN wp_rg_lead_detail ld ON l.id = ld.lead_id
    WHERE l.created_by=%d

    The only caviat is that this won't return you the data organized the way the entry object is.
    To do that you would need to make a call to RGFormsModel::build_lead_array(...);

    $entries = RGFormsModel::build_lead_array($results, true);

    The problem is that this method is private. I am not opposed to making it public as I can see it being useful in situations like this, but you will need to get a dev version of Gravity Forms from me. If you are interested, just email me at alex@rocketgenius.com and I will send it your way.

    Posted 12 years ago on Tuesday June 28, 2011 | Permalink
  3. Thanks, Alex. That's all I needed to know. I was hoping there was a quick function, but I'm okay with using an SQL statement.

    Posted 12 years ago on Tuesday June 28, 2011 | Permalink