Title: Set customized where using PHP when calling a form
Last modified: August 21, 2024

---

# Set customized where using PHP when calling a form

 *  Resolved [kitsufox](https://wordpress.org/support/users/kitsufox/)
 * (@kitsufox)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/set-customized-where-using-php-when-calling-a-form/)
 * I’m working on writing a PHP based form for a website using pods. I want to be
   able to use a customized WHERE set via the PHP instead of the dialog box for 
   setting up the field. I’ve done some searching but can’t find anything that says
   I can or can’t do this.
 * `'group_membership' => array( 'description' => 'MATCH TO OLD GROUP!
   This will
   activate the new system for this character.','customized_where' => 'secret.meta_value!
   = 1' )
 * So, if it’s possible, what do I call when I put it in the array where I’ve currently
   tried ‘customized_where’? I hope this works so that I can have multiple versions
   of the same form that only let the end user select from a limited list of options
   based on that customized where.

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

 *  Plugin Author [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * (@sc0ttkclark)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/set-customized-where-using-php-when-calling-a-form/#post-17965742)
 * Can you clarify what you are passing that PHP into?
 * You should try out using our `find()` method on the Pods object: [https://docs.pods.io/code/pods/find/](https://docs.pods.io/code/pods/find/)
 *  Thread Starter [kitsufox](https://wordpress.org/support/users/kitsufox/)
 * (@kitsufox)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/set-customized-where-using-php-when-calling-a-form/#post-17967801)
 * I’m passing it into form().
 * Here’s the complete bit of code that _might_ clarify what I’m attempting.
 * `$charpod = pods( 'characters', $charid )
   $fields = array('group_membership' 
   => array( 'description' => 'MATCH TO OLD GROUP!This will activate the new system
   for this character.','customized_where' => 'secret.meta_value != 1' ),'rank_assignment'
   => array( 'description' => 'MATCH TO OLD RANK!This will activate the new system
   for this character.' ));echo $charpod->form($fields);
 * Specifically, I want to be able to set the field setting “customized WHERE” in
   the advanced setting for a relationship field. But I’m not sure there’s a way
   to accomplish this dynamically based on what version of the form the end user
   is sent to?
    -  This reply was modified 1 year, 9 months ago by [kitsufox](https://wordpress.org/support/users/kitsufox/).
 *  Plugin Support [pdclark](https://wordpress.org/support/users/pdclark/)
 * (@pdclark)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/set-customized-where-using-php-when-calling-a-form/#post-17994037)
 * [@kitsufox](https://wordpress.org/support/users/kitsufox/) Parameters for a relationship
   field do not have a `where` argument because a query is not run — the specific
   IDs are stored.
 * However, one can override what items display as options in a relationship field
   by adding a query using the [pods_field_pick_data filter](https://github.com/pods-framework/pods/blob/20f681a61d80f9f4d272d7d407bf92d61ef8ade7/classes/fields/pick.php#L2259)
   or [pods_field_pick_data_ajax filter](https://github.com/pods-framework/pods/blob/20f681a61d80f9f4d272d7d407bf92d61ef8ade7/classes/fields/pick.php#L3271)
 * This filter will run for all relationship fields on frontend and backend, so 
   one can either attach the filter based on admin or frontend context, or modify
   behavior based on the field `$name` or other information passed to the function.
 * An example of using the first filter:
 *     ```wp-block-code
       <?phpadd_filter(    'pods_field_pick_data',    function( $data, $name, $value, $options, $pod, $id ) {        error_log(            print_r(                [                    'info' => sprintf( 'RELATIONSHIP FIELD named %s', $name ),                    '$data' => $data,                    '$name' => $name,                    '$value' => $value,                    '$options' => $options,                    '$id', => $id,                ]                true            )        );        return $data;    },    10,    6);
       ```
   
 * …where `return $data` sends the data to the field unmodified in all cases, while`
   print_r()` saves information for every relationship field that ran the filter
   to the PHP error log. `$pod` was left out of logging, as it would be an instance
   of the Pods object, which contains a lot of information.

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

The topic ‘Set customized where using PHP when calling a form’ is closed to new 
replies.

 * ![](https://ps.w.org/pods/assets/icon.svg?rev=3286397)
 * [Pods - Custom Content Types and Fields](https://wordpress.org/plugins/pods/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pods/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pods/)
 * [Active Topics](https://wordpress.org/support/plugin/pods/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pods/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pods/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [pdclark](https://wordpress.org/support/users/pdclark/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/set-customized-where-using-php-when-calling-a-form/#post-17994037)
 * Status: resolved