Forum Replies Created
-
AuthorPosts
-
mcaMember
but where are you devloper ? ! help !
best regart
mcamcaMemberMonday, and i still ask help …no progress in my problem 🙁
I need really fix that quick, thank you !
MCAmcaMemberI find the php function addslashes/ stripslashes() but i wonder where put a hook filter ?
mcaMemberYes you’re right i have to think about the way i want to do this :)In fact i use the form “both” like a registration form and a profile form…
Maybe it’s not a good idea ?
best regard,
mcamcaMember// get the custom field you want to use to store your role
why ?
i want to store the role in the data base filed wp_capabilities like that : a:1:{s:10:\”signataire\”;s:1:\”1\”;}// does it exist?
no there ins no field \”role\” on my form, i just test if ( current_user_can( \’signataire\’ ) ) i change the role.i try that (it work !) :
function tgm_custom_profile_redirect() {
if ( current_user_can( 'signataire' ) )
{
global $current_user;
get_currentuserinfo();
$current_user->remove_role('signataire');
$current_user->add_role('membre');
// wp_redirect( trailingslashit( home_url() ) );
// exit;
}
}
thank for your help !
mcamcaMember// get the custom field you want to use to store your role
why ?
i want to store the role in the data base filed wp_capabilities like that : a:1:{s:10:”signataire”;s:1:”1″;}// does it exist?
no there ins no field “role” on my form, i just test if ( current_user_can( ‘signataire’ ) ) i change the role.i try that (always wrong !) :
add_action( 'profile_update', 'my_profile_update');
function my_profile_update() {
if ( current_user_can( 'signataire' ) )
{
$current_user->remove_role('signataire');
$current_user->add_role('membre');
}
}
Can you explain me the logical processus to do what i want ton do ?mcaMembersorry there is still a mistake : i put this hook in the function.php file and i test it on a profile form create with user meta pro…
add_action( 'profile_update', 'my_profile_update' );
function my_profile_update($user_id) {
// get the user_meta field you care about here
if( isset($userData['signtomembre'])){
//$user = $userData['user_id'];
$user->remove_role('signataire');
$user->add_role('membre');
}
// get the user rolereturn true;
}mcaMemberthank you !
I try your hook but i can’t remove the role.
My function checks for the existence of the field “signtomembre” in the submitted data from the form, and if found, we know it’s a upgrade from signataire to member. So in my functions.php :add_action( 'profile_update', 'my_profile_update' );
function my_profile_update($user_id) {
if( isset($userData['signtomembre'])){
remove_role( 'signataire');
add_role( 'membre');
}return true;
}what is wrong ?
mcaMemberIn fact it’s the good hook but i don’t understand while i can’t update the field role ?
the filter hook (thank you toddz70 !) :add_filter('user_meta_pre_user_register', 'tz_registration_role');
function tz_registration_role($userData){
if( isset($userData['cacap'])){
// registration for demande
$userData['role'] = 'demandeur_adhesion';
} else {
// registration for membre
$userData['role'] = 'membre';
}
return $userData;
}thank’s for your help,
mcamcaMemberthank you idstm,
i create a new profile form and i’m looking for the name of the filter hook that i can use to filter my data before send the form. Where can i find that ?(I use this hook for my REGISTRATION “user_meta_pre_user_register”.)
mcaMemberthank you idstm,
i create a new profile form and i’m looking for the name of the filter hook that i can use to filter my data before send the form. I use this hook for my REGISTRATION “user_meta_pre_user_register”. Where ca i find that ?mcaMemberok you ‘re right.
mcaMemberYes it’s what i’m trying to do : a form that allows an existing user to change his role. i need some advice to do that 🙂
mcaMemberi use your hook on my two forms and it’s great!
But now i have one question : if the user want to upgrade his role (form school to student) he use the second form with the hidden field but your hook doesn’t achieve to upgrade his new role why ?
best regard,
mca -
AuthorPosts