Aladin00763 Posted June 17, 2017 Share Posted June 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
Aladin00763 Posted June 17, 2017 Author Share Posted June 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.