<?php//import from Ultimate MemberuseumcoreRoles_Capabilities;$isUltimateMember=true;//error_reporting(0);define('WP_USE_THEMES',false);require('../wp-load.php');//need this do workadd_action('profile_update','addUserRole',10,2);//register wordpress action//get params$role_STRING=$_REQUEST['role'];//new role$redirect_URL=$_REQUEST['url'];//link to URL after setting role$msg="Error";//message (displayed as GET Param)//check for redirect linkif(!isset($_REQUEST['url'])){$redirect_URL=home_url();}//verify if user is loggedif(is_user_logged_in()){//avoid user becomes admin or main wordpress rolesswitch($role_STRING){case"wpseo_manager":case"wpseo_editor":case"translator":case"subscriber":case"editor":case"contributor":case"author":case"administrator":$msg="User tried to become $role_STRING";$role_STRING="";exit(wp_safe_redirect("location: $redirect_URL?msg=$msg"));break;default://add user roleaddUserRole(wp_get_current_user()->ID,$role_STRING,$redirect_URL,$isUltimateMember);//get user ID}}$msg="User not logged in";//If user is not loggedexit(wp_safe_redirect("location: $redirect_URL?msg=$msg"));functionaddUserRole($user_ID,$role_STRING,$redirect_URL,$isUltimateMember=false){if($isUltimateMember){//add roles to ultimate member plugin$u=newRoles_Capabilities();$u->set_role($user_ID,$role_STRING);//add a new user-role for user->ID}else{//add role normal$u=newWP_User($user_ID);//pick a past user Role$u->add_role($role_STRING);//add a new user-role for user->ID}$msg="Role added";exit(wp_safe_redirect("location: $redirect_URL?msg=$msg"));//redirect to page}