David Junior
Forum Replies Created
-
Forum: Plugins
In reply to: [User Role Editor] Changing a user’s role with a buttonHi Everyone
O Solved my job with this code:
<?php define('WP_USE_THEMES', false); require('wp-load.php'); //need this do work add_action( 'profile_update', 'my_profile_update', 10, 2 ); if (is_user_logged_in()){ //verify if user is logged $user = my_profile_update(wp_get_current_user()->ID); //get user ID echo array_shift($user->roles); }else{ //If user is not logged Header( "location: https://mysite.com"); } function my_profile_update( $user_id ) { //if user is logged $u = new WP_User( $user_id ); //pick a past user Role $u->set_role('role-created'); //Set a new user-role for user->ID Header( "location: https://mysite.com");//redirect to page return $u; } ?>I create a new page user-role.php and call this page on a button and every user who call the function change de user-role.
This work fine to me and and must be help for more programers.
Tanks!!
Forum: Developing with WordPress
In reply to: Changing user’s function with sql and php codeThanks for the help and the information was a great help.
As I’m trying to create a QR Code reader to make these changes for me I decided to make a page and not a plugin or a call in the includ.php of the theme, so it looked like this:add_action( 'profile_update', 'my_profile_update', 10, 2 ); if (is_user_logged_in()){ $user = my_profile_update(wp_get_current_user()->ID); echo array_shift($user->roles); }else{ echo "<br><p>Deslogado<br></p>"; } function my_profile_update( $user_id ) { $u = new WP_User( $user_id ); $u->set_role('subscriber'); return $u; }So whenever I call this page.php it looks up the current logged-in user ID and changes its role.
Now a next doubt taking advantage of the open forum:
I need to create a QR Code reader that will call this page for all the readers I encounter or it from the problem with the Android camera or IOS camera, someone knows some way or some library to make it work for both.
Or wordpress has something similar already developed.Thank you so far for everything!
Forum: Developing with WordPress
In reply to: Changing user’s function with sql and php codeThanks for the info, I have solved the problems to create the capabilities, I found a plugin that helped me very well, now my problem is in creating a function for the user to select which role he wants to belong ‘sun’ or ‘moon’.
Ex. I register and I want to belong to the sun group so I click on the button ‘Participate in the sun group’ or ‘Join the moon group’
However I am still in doubt on what functions I should work on and how my SQL should handle those changes.
Forum: Fixing WordPress
In reply to: Error while trying to show calendarThe Name of the Plugin is The Events Calendar Version 4.6.2 | By Modern Tribe, Inc.
the plugin I downloaded from wordpressThe theme is Lost World Version: 3.5 by designthemes the theme eh buy from themeforest.net