• 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 3 years, 1 month ago by ranone.
    • This topic was modified 3 years, 1 month ago by ranone.
    • This topic was modified 3 years, 1 month ago by ranone.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author xnau webdesign

    (@xnau)

    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()

    Thread Starter ranone

    (@ranone)

    Tks @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

    (@xnau)

    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 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

    Thread Starter ranone

    (@ranone)

    Hi @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

    (@xnau)

    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.

    Thread Starter ranone

    (@ranone)

    Hi @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

    (@xnau)

    You can use

    <?php
    $record_id = Participants_Db::get_participant_id( $private_id );
    ?>
    Thread Starter ranone

    (@ranone)

    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!

    • This reply was modified 3 years, 1 month ago by ranone.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Get record object in function.php file’ is closed to new replies.