Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //this is default variable if nothing is submitted with my form
- $the_user_garden = "gardens";
- ?>
- <?php
- //this is the form that will change the variable
- if(isset($_POST['submit']))
- {
- $the_user_garden = $_POST['sub_garden_1'];
- }
- ?>
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
- <input type="text" name="sub_garden_1" value="sub_garden_1"><br>
- <input type="submit" name="submit" value="Submit Form"><br>
- </form>
- <?php
- //this put the new variable value from the form as session variable
- $_SESSION['myKey'] = $the_user_garden;
- ?>
- <?php
- $author_id = get_current_user_id( );
- //this is where I am using the changes variable
- if( have_rows($the_user_garden, 'user_'.$author_id) ): ?>
- <?php
- //and here too
- while( have_rows($the_user_garden, 'user_'.$author_id) ): the_row(); ?>
- <?php
- add_action('init', 'myStartSession', 1);
- add_action('wp_logout', 'myEndSession');
- add_action('wp_login', 'myEndSession');
- function myStartSession() {
- if(!session_id()) {
- session_start();
- }
- }
- function myEndSession() {
- session_destroy ();
- }
- ?>
- <?php
- // this is where I need the variable for gravity form(pop up)
- if(isset($_SESSION['myKey'])) {
- $the_user_garden = $_SESSION['myKey'];
- } else {
- $the_user_garden = "gardens";
- }
- ?>
- <?php
- //this is where I am using variable
- $author_id = get_current_user_id( );
- if( have_rows($the_user_garden, 'user_'.$author_id) ): ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement