Jump to content

Question about my code php for save content in coockies


Aladin00763

Recommended Posts

hello i created this code for make our users in our wordpress can change their role by plugin code php widget 
so this is my code  :

hello i created this code for make our users in our site can change their role usrs in wordpress by plugin php code widget :
this is the code if someone can help for verify why isn't working thank you evry one :)
<html>
<body>
<?php if(!isset($_COOKIE[$cookie_name])){ ?>
<form method="get">
<input type="submit" name="oui" value="oui" id="submit1">
<input type="submit" name="non" value="non" id="submit2">
</form>
 <?php }
</body>
</html>
<?php
if(isset($_GET['oui'])) {
onFunc(); 
$cookie_name = "user";
$cookie_value = "user2";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); 
}
if(isset($_GET['non'])) {
 offFunc();
}
 function onFunc(){ 
global $current_user; 
get_currentuserinfo();
 if((user_can($current_user ,'7eme'))
{
// Remove role
$current_user->remove_role( '7eme' );
// Add role
$current_user->add_role( 'contributor' );
echo "..votre niveau scolaire maintenant est 8ème année de base";
}
function offFunc(){
echo "Bonne chance  la deuxième fois";
}?> 
so if some can help me for make this code working i will so appreciated :)
Best regards
Link to comment
Share on other sites

after some modification in my code : this :

<?php if(!isset($_COOKIE[$cookie_name])){ ?> 
 <html>
<body>
        <form method="get">
            <input type="submit" name="oui" value="oui" id="submit1">
            <input type="submit" name="non" value="non" id="submit2">
        </form>
</body>
</html>
 ?>}
<?php
$cookie_name = "user";
$cookie_value = "user2";
    if(isset($_GET['oui'])) {
onFunc(); 
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); 
}
    if(isset($_GET['non'])) {
        offFunc();
    }
 function onFunc(){ 
global $current_user; 
get_currentuserinfo();
 if((user_can($current_user ,'7eme'))
   {
       // Remove role
       $current_user->remove_role( '7eme' );
 // Add role
       $current_user->add_role( 'contributor' );
        echo "..votre niveau scolaire maintenant est 8ème année de base";
   } 
    }
    function offFunc(){
        echo "Bonne chance  la deuxième fois";
    }?>
now the error displaying like this : 
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\wptest\wp-content\plugins\php-code-widget\execphp.php(27) : eval()'d code on line 25
 
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.