Role Editor and different Activation - Pie Register
2019-04-24 21:39:55

Role Editor and different Activation

Home Forums News & Announcements Role Editor and different Activation

This topic contains 3 replies, has 2 voices, and was last updated by  Pie Register 3 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #4023

    Gabriel Costa

    Hello 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.



    Pie Register


    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.



    Gabriel Costa

    Hey Hasnain, tks for your reply, but it’s not working. I tried =(

    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?


    Pie Register

    As i have told you, please try to use the following:
    add_action(“pie_register_after_register_validate”,”my_custom_user_role_cb”, 10, 1);


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.