Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5838
    moko
    Participant

    Hi,

    I use WP Ultimo on my multisite install. I have URE Pro activated.

    To add another role to a user, I have to do it manually.

    WP Ultimo has “subscription plans” and I can assign just one custom role via URE for each plan. However, I want to add another custom_role upon registration via code – since this is the only way I can think of right now.

    In summary, upon users’ registration, they should have the role I assigned from WP Ultimo AND the other custom role via code automatically.

    I want to add the code via a normal plugin or MU-plugins.

    I look forward to hearing your solution(s).

    Kind regards,
    Mo

    PS: Vladimir, I am open to share my website’s credentials for you to take a closer look.

    #5842
    Vladimir
    Keymaster

    Hi,

    May be this code will give a starting point:

    
    if (is_multisite()) {
        add_action( 'wpmu_activate_user', 'add_secondary_role', 10, 1 );
    } else {
        add_action( 'user_register', 'add_secondary_role', 10, 1 );
    }
    
     
    function add_secondary_role( $user_id ) {
     
        $user = get_user_by('id', $user_id);
        $user->add_role('custom_role_id');
     
    }
    

    I will be out of office until July 31st.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.