Skip Navigation

[Resolved] No id in the URL shows all records

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 7.07 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by Minesh 4 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2706122
Untitled-4.jpg

I have a view that shows the details of the user id in the URL, and it works when there is a number in the URL, it works when there is incorrect number in the URL, i.e. it shows nothing, but remove the number and you get to see everything.

The correct response is to show nothing, since it matches nothing, this should be fixed ASAP.

It gets worse. I created a view in the block editor, and have it show all records where user_id matches the URL param, and if there is a number in the URL but no user_id it shows everything. If I create a view for this then it works as expected when the number doesn't exist.

I'm guessing it's because in the block editor, you can't specify that it's a number. Still, if the view is created, and you leave the param blank, it shows everything, MAJOR MAJOR issue.

Here's what I mean by leaving it blank
?member_id=

These are some major issues.

#2706224

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to know - are you using custom search view with AJAX or you are just listing items where user_id matches the URL param?

Can you please confirm and once you share this information I will be able to guide you in the right direction.

In addition to that - Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

#2706225

"I would like to know - are you using custom search view with AJAX or you are just listing items where user_id matches the URL param?"

1) View purpose Display all results
2) Include only posts with IDs determined by the URL parameter "requestid" eg. yoursite/page-with-this-view/?requestid=1
3) No pagination

Let me know if you need more info

#2706227

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please try to add the following filter code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset

function func_hide_results_until_filer_fired( $view_args, $view_settings, $view_id )  {
  
  $target_view_ids = array(999999);

  if (in_array( $view_id, $target_view_ids )) {
      
    if(!isset($_REQUEST['member_id'])) {
      
        $view_args['post__in'] = array(0);
    }
     
  }
    
  return $view_args;
}
add_filter( 'wpv_filter_query', 'func_hide_results_until_filer_fired', 101, 3 );

Where:
- Replace 999999 with your original view ID

I hope the solution shared above will help you to resolve your issue.

#2706253

Are you saying it's normal behavior and I need to implement this for every view?

#2706278

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - its normal behavior.

Well, if you want to apply the same to multiple views, you can add your target view IDs with the $target_view_ids variable.

For example:

function func_hide_results_until_filer_fired( $view_args, $view_settings, $view_id )  {
   
  $target_view_ids = array(999999,888888,77777,66666,55555);
 
  if (in_array( $view_id, $target_view_ids )) {
       
    if(!isset($_REQUEST['member_id'])) {
       
        $view_args['post__in'] = array(0);
    }
      
  }
     
  return $view_args;
}
add_filter( 'wpv_filter_query', 'func_hide_results_until_filer_fired', 101, 3 );

Where:
- Adjust the multiple view IDs with variable $target_view_ids which is assigned array with values 999999,888888,77777,66666,55555 with your original view IDs