php - Advance custom fields variable with if statement & Function

I'm new in php & WordPress in general but I searched all the stackexchange website to find the proper advice wi

I'm new in php & WordPress in general but I searched all the stackexchange website to find the proper advice with no luck so I hope I ask in proper way.

I have simple PHP function with if statement look like this:

function wp_admin_restrection(){
            if( !current_user_can('administrator') && $wpAdminRestrection ){

              do something
            }
         }

Where $wpAdminRestrection = get_field('disable_wp_admin_for_non_admin', 'option');

My problem is, the above function not working as its written but if I write like this:

function wp_admin_restrection(){
                if( !current_user_can('administrator') && get_field('disable_wp_admin_for_non_admin ){

                  do something
                }
             }

it will work with no issue.

According to ACF documentation , I should use get_field for this situation and not the_field.

Would you please advise me?

NOTE This seem to only happen with True/False field as its working fine with other fields so far.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744726200a4590193.html

相关推荐

  • php - Advance custom fields variable with if statement & Function

    I'm new in php & WordPress in general but I searched all the stackexchange website to find the proper advice wi

    7天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信