Skip Navigation

[Resolved] Shortcodes with parameters upgrade after error php 8 (pt. 2)

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. 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 8 replies, has 2 voices.

Last updated by dmitryK-2 1 year, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2371127

Tell us what you are trying to do?
- this is continued from original thread https://toolset.com/forums/topic/shortcodes-with-parameters-upgrade-after-error-php/

Is there any documentation that you are following?
-

Dear Jamal, can we please continue Toolset to php8 topic from link above, from you last code snippet to be exact. When I insert it to functions.php WP gives me an critical error "syntax error, unexpected T_DOUBLE_ARROW [duplicate]" for line of code

 $query_args['meta_query'] => array( 

My php is quite low to fix this, can you please take a look what's wrong, also find a topic here - https://stackoverflow.com/questions/20365334/php-syntax-error-unexpected-t-double-arrow

Thanks in advance!

//Return only posts from the current author when listing posts of type company:
add_filter( 'wpv_filter_query', 'prefix_for_specific_email', 20, 3 );
  
function prefix_for_specific_email( $query_args, $view_settings, $view_id ) {
    if ( in_array( $view_id, array( 123, 456) ) ){
        $query_args['meta_query'] => array(
            array(
                'key'     => '_billing_email',
                'value'   => wpv_do_shortcode('[wpv-user field="user_email"]"]'),
                'compare' => '=',
            ),
        );
    }
    return $query_args;
}
#2371445

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Could you please try to use the following code and try to resolve your issue:

//Return only posts from the current author when listing posts of type company:
add_filter( 'wpv_filter_query', 'prefix_for_specific_email', 20, 3 );
   
function prefix_for_specific_email( $query_args, $view_settings, $view_id ) {
    if ( in_array( $view_id, array( 123, 456) ) ){
        $query_args['meta_query'] = array(
            array(
                'key'     => '_billing_email',
                'value'   => wpv_do_shortcode('[wpv-user field="user_email"]"]'),
                'compare' => '=',
            ),
        );
    }
    return $query_args;
}

I just changed the assignment from => sign:

   $query_args['meta_query'] => array(

To = sign:

   $query_args['meta_query'] = array(
#2371469
2022-05-26_09-24-14.png

Hi Minesh, thanks for reply, error gone.

The ID's of View this filter should work are 5698, 7081
I've also change it in code. No errors from php standpoint.

 if ( in_array( $view_id, array( 5698, 7081) ) ){

As for now, my two views have the following (former) shortcode inserted on site page, showing no results (see attached)):
-- View ID 5698

<div>[wpv-view name="mysht-list-all-orders" email="[wpv-user field="user_email"]"]</div>

-- View ID 7081

<div>[wpv-view name="mysht-list-all-orders-others" email="[wpv-user field="user_email"]"]</div>

Should I remove 'email' parameter from the shortcodes above and make them like this after adding code to functions.php ?
View ID 5698 (with 'prefix_for_specific_email' code in functions.php):

<div>[wpv-view name="mysht-list-all-orders"]</div>

View ID 7081 (with 'prefix_for_specific_email' code in functions.php):

<div>[wpv-view name="mysht-list-all-orders-others" ]</div>
#2371487

Minesh
Supporter

Languages: English (English )

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

As per our support policy, we entertain only one question per ticket. This will help other users searching on the forum as well as help us to write correct problem resolution summery.

I'll split the ticket with your new question and you are welcome to mark resolve this ticket.

We will continue with the following new ticket:
=> https://toolset.com/forums/topic/split-shortcodes-with-parameters-upgrade-after-error-php-8-pt-2-filer-view-by-shortcode-attribute/

#2371491
2022-05-26_09-36-21.png

I think it is also important, Jamal mentioned:
"The views are expecting a shortcode argument to match against a custom field, with a post status filter, and a text search filter. You can replace the shortcode attribute by a custom code that hooks into the views' query filters. "

Please have a look at Query Filter setting , I have in a View ID 5698 (same in View ID 7081), should it remains the same or need to be changed ?

#2371503

Minesh
Supporter

Languages: English (English )

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

As shared:

We will continue with the following new ticket:
=> https://toolset.com/forums/topic/split-shortcodes-with-parameters-upgrade-after-error-php-8-pt-2-filer-view-by-shortcode-attribute/

You are welcome to mark resolve this ticket.

#2371507

Hm, looks like here

function prefix_for_specific_email( $query_args, $view_settings, $view_id ) {

the '$view_settings,' is not used anywhere and empty.. Remove it?

#2371511

Minesh
Supporter

Languages: English (English )

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

I've created separate ticket here:
=> https://toolset.com/forums/topic/split-shortcodes-with-parameters-upgrade-after-error-php-8-pt-2-filer-view-by-shortcode-attribute/

I'll follow-up there, please close this ticket.

#2371641

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.