• Resolved Dan Stramer

    (@danstramer)


    Hello,

    Once upgrading to PHP 8, we encountered a fatal error because of using this function:

    add_filter( 'post_class', 'um_add_restricted_class_css', 10, 1 );

    function um_add_restricted_class_css($classes){
    global $post;
    $restriction = get_post_meta( $post->ID, 'um_content_restriction', true );

    // if the post is restricted do this.
    if ( $restriction['_um_accessible'] == 2 ){
    $classes[] = 'um-restricted-content';
    }

    return $classes;
    }

    Can you please advise?

    Thank you,

    Dan

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

    (@missveronicatv)

    @danstramer

    You can try with this update

    if ( isset( $restriction['_um_accessible']) && $restriction['_um_accessible'] == 2 ){

    Thread Starter Dan Stramer

    (@danstramer)

    Thanks, this works.

    Is this related to PHP 8 syntax?

    Dan

    missveronica

    (@missveronicatv)

    @danstramer

    Yes, you can’t access an element of an array
    without first testing if it’s an existing element
    then you can test if the element’s value is equal to 2.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.