First Page: I have a form that links to the second page when the submit button is pushed.
<form action='http://localhost/wordpress/secondpage/' method='get'>
<input class='changeDataButtons' type='submit' name='activate' value='Activate' />
</form>";
Second Page: I check if the "Activate" button was pushed and I activate a second menu in my wordpress site.
if(isset($_GET['activate']))
{
my_wp_nav_menu_args();
}
function my_wp_nav_menu_args($args = '')
{
$args['menu'] = 'Menu 2';
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
I also have a form in the second page that link to the first page when the submit button is pushed.
<form action='http://localhost/wordpress/firstpage' method='get'>
<input class='changeDataButtons' type='submit' name='deactivate' value='Deactivate' />
</form>";
First Page: I check if the "Deactivate" button was pushed and I activate the first menu in my wordpress site.
if(isset($_GET['deactivate']))
{
my_wp_nav_menu_args();
}
function my_wp_nav_menu_args($args = '')
{
$args['menu'] = 'Menu 1';
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
Everything works fine but when I close the browser, $_GET gets to zero and Menu 1 is activated again. Is there a way to keep $_GET value? I thought about using sessions and set a cookie with an expire time, but I don't want it to expire. Thanks in advance.