• Resolved jjuvilla

    (@jjuvilla)


    I am trying to filter a pods ui via pods_ui function but filtering by a meta data, but is not working. This is my code:

    public function custom_group_tab_content() {

    $invite_crud = pods(‘invitaciones’);

    $fields = array();
    foreach($invite_crud->fields as $field => $data) {

      $fields[$field] = $data;
    
      if ($field == 'id_grupo') {
        $fields[$field]['default'] = bp_get_current_group_id();
      }
    
      if ($field == 'id_invitador') {
        $fields[$field]['default'] = bp_loggedin_user_id();
      }

    }

    $invite_crud->ui = array(
    // ‘item’ => ‘Invitación’,
    // ‘items’ => ‘Invitaciones’,
    ‘fields’ => array(
    ‘add’ => $fields,
    ‘edit’ => $fields,
    ‘duplicate’ => $fields,
    ‘manage’ => $fields,
    )
    );

    pods_ui($invite_crud, [‘where’ => ‘id_grupo.meta_value = ‘ . bp_get_current_group_id()]);
    }

    Whats wrong in my code?

    Thanks and regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Paul Clark

    (@pdclark)

    It’s not totally clear what you’re trying to do, and it’s difficult to test the code without a Pods Config export and knowledge of your BuddyBoss setup. But since you said the issue is getting all invitaciones, not those related to the group, the issue is probably with your WHERE query:
    'id_grupo.meta_value = ' . bp_get_current_group_id()
    …perhaps id_grupo is a relationship field? According to the docs, if id_grupo is a relationship field:

    my_relationship_field.ID Reference the related ID from the field “my_relationship_field”.

    https://docs.pods.io/code/pods/find/find-reference-table/#Relationship_File_Field_Traversal

    So:
    sprintf( 'id_grupo.ID = %d', bp_get_current_group_id() )
    or
    'id_grupo.ID = ' . (int) bp_get_current_group_id()

    Also verify that bp_get_current_group_id() is returning the ID of the group you’re looking for in the context that you’re running this function. Looking at the source on https://www.buddyboss.com/resources/reference/functions/bp_get_current_group_id/, I would only expect that function to work on a group page.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jjuvilla

    We havent heard from you anymore so I’m closing this topic.
    Feel free to reopen if you still need help!

    Cheers, Jory

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter via where in pods_ui’ is closed to new replies.