Why my sql extraction is not filtering the data properly on wordpress pages with a specific php variable

Viewed 11

I am new to sql, php etc.. I am using a plugin called EZ to create sql queries and extract data from my database. I have created a query which works properly. Now I would like to add a php variable to it to automatize the process and generate the correct set of data depending on the current user id viewing the page. The current user (post author) should see only the data linked to the posts for which he is the author.

I created the query on the plugin side and got a shortcode for each query created that I inserted on my page.

The query created looks like:

Select SELECT woo_order_id.....
FROM wp_byt_cruise_booking....
.....
.....
WHERE woo_status ='processing' OR woo_status ='completed'
AND post_author='<?php get_current_user_id()?>'
ORDER BY _Booking_Date_;

When the user is different from admin, then the data is not filtered properly and the lines of all the post authors appear in the list. It looks like it is not able to get the current user.

How can I correct that?

Thanks for your leads!

0 Answers
Related