- This topic has 3 replies, 2 voices, and was last updated 10 years, 10 months ago by
Pie Register.
- AuthorPosts
- September 22, 2015 at 7:05 pm #10004023
Gabriel CostaParticipantHello there.
Have two days i’m trying to make a function to change the option(‘default_role’) and save with my own role, where I choose in the register form, but I don’t know what can I do.
look my code.
add_action('pie_register_after_register_validate','my_custom_user_role_cb', 10, 1); function my_custom_user_role_cb($user){ $new_role = $_POST['radio_5']; $user = wp_update_user( array ('ID' => $user_id, 'role' => $new_role ) ) ; }And I need to approve the account instantly when the user role is like ‘customers’ and when the role is ‘distributors’, only the admin can approve the account.
How can I do these two functions in the action ‘pie_register_after_register_validate’..???
Could you help me, please.
Tks..
September 23, 2015 at 4:40 pm #10004026
Pie RegisterParticipantHello,
Please use update_user_meta instead of wp_update_user
You can approve them using:
update_user_meta( $user_id, ‘active’, 1);Hope it helps.
Thanks
September 23, 2015 at 4:52 pm #10004028
Gabriel CostaParticipantHey Hasnain, tks for your reply, but it’s not working. I tried =(
look.add_action( 'user_register', 'my_custom_user_role_cb', 10, 1 ); function my_custom_user_role_cb( $user_id ) { if ( isset( $_POST['radio_5'] ) ) { update_user_meta($user_id, 'role', 'custormers'); // wp_update_user( array ('ID' => $user_id, 'role' => 'customers' ) ) ; } }I think the problem is with the $user_id, It’s return ‘null’.
Some thing else?
September 28, 2015 at 3:44 pm #10004049
Pie RegisterParticipantAs i have told you, please try to use the following:
add_action(“pie_register_after_register_validate”,”my_custom_user_role_cb”, 10, 1);Thanks
- AuthorPosts
- The forum ‘News & Announcements’ is closed to new topics and replies.
