Title: Get record object in function.php file
Last modified: October 7, 2021

---

# Get record object in function.php file

 *  [ranone](https://wordpress.org/support/users/ranone/)
 * (@ranone)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/)
 * Hi,
    I need to get the record object into function.php file.
 * I would like retrieve dynamically a record value to use it into the [pdb_record]
   shortcode and add a group based on the value of this field..
 * It’s possible?
 * Below my simple code into function.php file:
 *     ```
       add_shortcode( 'pdb_record_custom', 'pdb_record_custom_shortcode' );
       function pdb_record_custom_shortcode() {
   
          $record = XXX exist a simple record getter XXX;
   
          return '[pdb_record groups="main,'. $record->fields['field_name']->value() .'"]';
       }
       ```
   
 * Tks for the support
    -  This topic was modified 4 years, 7 months ago by [ranone](https://wordpress.org/support/users/ranone/).
    -  This topic was modified 4 years, 7 months ago by [ranone](https://wordpress.org/support/users/ranone/).
    -  This topic was modified 4 years, 7 months ago by [ranone](https://wordpress.org/support/users/ranone/).

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14948819)
 * I’m not sure I understand what you’re trying to accomplish here…
 * I have an article that may be helpful:
 * [Placing Dynamic Shortcodes using do_shortcode()](https://xnau.com/placing-dynamic-shortcodes-using-do_shortcode/?swcfpc=1)
    -  This reply was modified 4 years, 7 months ago by [xnau webdesign](https://wordpress.org/support/users/xnau/).
 *  Thread Starter [ranone](https://wordpress.org/support/users/ranone/)
 * (@ranone)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14951525)
 * Tks [@xnau](https://wordpress.org/support/users/xnau/) for your reply 🙂
 * I have created many groups in the “Database Fields Management” section and after
   I have created also a select field with values ​​that have the same name of the
   groups.
 * When I go to the edit page ([pdb_record] shortcode), I would like to display 
   only the group that has the same name of the value of the select field by means
   of the attribute of the pdb_record shortcode (groups=””)..
 * I don’t know if that is how I explained myself better..
 * Tks
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14952222)
 * OK, something like this has to be done using javascript. You will need to write
   some custom code that responds to the user’s selection. The best way to do that
   is to use a [custom template](https://xnau.com/work/wordpress-plugins/participants-database/participants-database-documentation/pdb-templates/)
   where you can put your javascript.
 * I have a tutorial that explains how to do something like this, but you will need
   to modify the javascript so that it shows or hides groups based on the user’s
   selection.
 * [Dropdown Selectors: limit selections based on another selector ](https://xnau.com/dropdown-selectors-limit-selections-based-on-another-selector/?swcfpc=1)
 *  Thread Starter [ranone](https://wordpress.org/support/users/ranone/)
 * (@ranone)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14956943)
 * Hi [@xnau](https://wordpress.org/support/users/xnau/), thanks for the reply.
 * I don’t have to use it at the template level (ok for that use) …
 * I would like to know if there is a static getter method to get the current record
   inside the function.php file in my child theme.
 * Regards
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14959600)
 * You can get the record data using a method like this:
 * `$record = Participants_Db::get_participant($id);`
 * That will return an associative array of values.
 * Be aware of the fact that this won’t work if you call it before the plugin is
   initialized.
    -  This reply was modified 4 years, 7 months ago by [xnau webdesign](https://wordpress.org/support/users/xnau/).
 *  Thread Starter [ranone](https://wordpress.org/support/users/ranone/)
 * (@ranone)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14961970)
 * Hi [@xnau](https://wordpress.org/support/users/xnau/),
    I’ve the private_id (
   not the record id) as available variable.
 * Can I use it in any way?
 * Tks
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14963521)
 * You can use
 *     ```
       <?php
       $record_id = Participants_Db::get_participant_id( $private_id );
       ?>
       ```
   
 *  Thread Starter [ranone](https://wordpress.org/support/users/ranone/)
 * (@ranone)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14970080)
 * Hi,
    the “Participants_Db::get_participant_id” didn’t work for me with **$private_id**,
   so I used this approach:
 * `$record_id = Participants_Db::get_record_id_by_term('private_id', $_GET['pid']);`
 * Not the best, but this works for me..
 * Tks a lot for all [@xnau](https://wordpress.org/support/users/xnau/)!
    -  This reply was modified 4 years, 7 months ago by [ranone](https://wordpress.org/support/users/ranone/).

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Get record object in function.php file’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

## Tags

 * [function.php](https://wordpress.org/support/topic-tag/function-php/)

 * 8 replies
 * 2 participants
 * Last reply from: [ranone](https://wordpress.org/support/users/ranone/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/get-record-object-in-function-php-file/#post-14970080)
 * Status: not resolved