• Resolved rayan

    (@rayan)


    I am having difficulty setting up a box that is only shown to users who are not logged in and also only shown on specific pages. When I copy the example in the KB, it doesn’t show to logged in users, but it doesn’t follow the conditions set on the box set up page.

    Does the lock down to specific pages need to be done with the filter hook as well?
    Is there a code example of how to do this?

    https://www.ads-software.com/plugins/boxzilla/

Viewing 1 replies (of 1 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Rayan,

    To take the existing box rules (from the box settings screen) into account you need to check the first parameter value of the filter callback function.

    Here’s an example:

    add_filter( 'boxzilla_load_box', function( $load, $box_id ) {
    	return $load && ! is_user_logged_in();
    }, 10, 2 );

    This will only show the box when the box rules have been matched AND the user is not logged in.

    Hope that helps. If not, let me know!

    PS. Should you have a quick minute to spare, a plugin review here on www.ads-software.com would make us quite happy. ??

Viewing 1 replies (of 1 total)
  • The topic ‘Only show for users not logged in’ is closed to new replies.