Utilizing Password Protection With Oxygen

Sometimes, you may find yourself wanting to use the default Password Protected Page system in WordPress alongside Oxygen. Unfortunately, this doesn’t work by default with Oxygen, as it stores the data it saves within the wp_postmeta field and the default WordPress Password Protected Page feature shows, or hides, the post’s content, which is found within the iwp52cc_posts table.

Luckily, we can use Oxygen’s Conditions API to utilize the default WordPress Password Protected Page. With the following snippet, we’re going to create two different functions that we’ll use on our target page:

/* Registers the Password Required condition in Oxygen */
if(function_exists('oxygen_vsb_register_condition')) {
 global $oxy_condition_operators;
 oxygen_vsb_register_condition('Password Required',array('options'=>array('true','false'), 'custom'=>false),$oxy_condition_operators['simple'],'lux_condition_password_check','Post');
 function lux_condition_password_check($value, $operator) {
  if ( post_password_required() ) {
   $result = 'false';
  } else {
   $result = 'true';
  return oxy_condition_eval_string($result,$value,$operator);

/* Quick function for displaying the Password Protection plugin */
function lux_check_password_status() {
 if ( post_password_required()) {
  echo get_the_password_form();

The first function registers a new Oxygen condition called “Password Required” under the Posts section. The second function will be used to show the password form.

showing the content After Password Protection is Validated

Our first step is to use the Password Required condition to only show elements on a page after a user has entered the page’s password. This is done by using the condition, operator, and value of “Password Required == true”.

So, for example, if we set our Inner Content element, or Text element containing the Post Content, the element will be hidden until the password has been entered and the user refreshes the page.

Displaying the Pasword Protection Form

Now that we’ve got that set up, our next step is to actually set up a way for user’s to enter the password. To do this, add a Code Block element with the following PHP:


This code will add a password form that the user can then enter the password. Once submitted, the page will refresh, and the hidden content should now show on the page. You could go a step further with the Code Block element and apply the condition “Password Required == false” to ensure the function doesn’t even run if the password has been entered.

That’s all we need to use the built-in WordPress Password Protection system with Oxygen. Happy voyages!

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    © 2020-2024 Luxibay
    Please let us know what's on your mind. Have a question for us? Ask away.
    This field is for validation purposes and should be left unchanged.