2

I'm trying to implement this password protected content method on a v2.1.3 build.

This code...

<?php
global $IN;

if ( ! $the_password = $IN->GBL('the_password', 'POST') ) :

?>

...returns an error

Fatal error: Call to undefined method EE_Input::GBL() in  /homepages/42/d186459053/htdocs/dri/expressionengine/libraries/Functions.php(650) : eval()'d code on line 17

After some research, it looks like part of this has been deprecated.

Instead I should be using...

ee()->input->post('the_password');

However, after reading this, it looks like the

global ee() function is only available since EE 2.6.0

Upgrading EE at this time isn't an option. What could I do to to retrieve the POST variable in this instance so this method works?

1

The ee() function in 2.6+ is just a shortcut to another function, get_instance(), which appears in ALL versions of EE.

<?php
$EE =& get_instance();
if ( ! $the_password = $EE->input->post('the_password') ) :
?>
| improve this answer | |
1

So the correct answer to your question is the correct global ee() function for the version of EE you named is...

$this->EE =& get_instance();

$this->EE // is the 2.6+ ee() equivalent.

| improve this answer | |
0

Managed to get it working with the following code

<?php if (! $the_password = $this->EE->input->post('the_password')) : ?>

<form action="" method="post">
 <p>
  Enter your password:<br/>
  <input type="password" name="the_password" value="" id="the_password" />
  <input type="submit" name="submit" value="Access Content &rarr;" id="submit" />
 </p>
</form>
<?php else : ?>
{exp:channel:entries channel="private_content" 
 url_title="<?php echo $the_password;?>" 
 dynamic="off" limit="1"}

 {if no_results}<p>Your password is incorrect. Would you like to
    <a href="{path='private'}">try again</a>?</p>{/if}

 {private_content}

{/exp:channel:entries}
<?php endif; ?> 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.