php – Else condition not working

Question

I have a page that shows submit for of Advance custom field plugin. I want to show the form for users been logged in and have admin permissions. I use the if condition to create this and it works fine but else condition doesn’t print any result. Here is my code :

        if( is_user_logged_in() == true ) {

        $user = wp_get_current_user();
        $allowed_roles = array( 'administrator' );

        if( array_intersect( $allowed_roles, $user->roles ) ) { 

            if( have_posts() ) {

                acf_form(array(
                    'post_id'       => 'new_post',
                    'new_post'      => array(
                        'post_author'   => 1,
                        'post_type'     => 'warehouse',
                        'post_status'   => 'publish'
                    ),
                    'submit_value'  => 'ثبت رسید'
                ));

            }

        }

    } else {

        echo ':(';

    }

0
Mehran Pourjenabi 2 weeks 2023-09-17T04:05:51-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse