Role Editor and different Activation - Pie Register
2018-12-11 23:05:02

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, 2 months ago.

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

    Gabriel Costa
    Participant

    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.

    Tks..

    #4026

    Pie Register
    Keymaster

    Hello,

    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

    #4028

    Gabriel Costa
    Participant

    Hey 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?

    #4049

    Pie Register
    Keymaster

    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);

    Thanks

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

You must be logged in to reply to this topic.