BuddyDev

Search

Setting Member Types (with Members Types Pro) on user-new.php form

  • Participant
    Level: Enlightened
    Posts: 23
    y2gabs on #18939

    Thank you sir! That worked. One sort of unrelated question remains and I’ve been searching all day for a fix – Given that we’re setting the new user’s role with this function, can you recommend a way to remove the user role drop-down from the user-new form? It’s defaulting to the default role and overriding any role set by the function.

    Thank you for your help!

  • Keymaster
    (BuddyDev Team)
    Posts: 22201
    Brajesh Singh on #18953

    Hi Jeff,
    No problem.

    The role selected should not override our role. user_register action is fired after the default role is set so our role should override it(the role must exist).

    If it is not working, you may try by switching to

    
    edit_user_created_user
    

    action instead of ‘user_register’

    If it is for aesthetics reason(hiding from display, please use css).

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 23
    y2gabs on #18954

    Thanks for the update! Unfortunately that didn’t work, infact modifying the action with edit_user_created_user instead of user_register fails to set the member type (leaves it blank) :/. A little further information if it helps – I’m including this code in the functions.php, not sure if that affects the priority or order in which the role is set (by form element or by our code).

    Yes, I can hide the element with css. I was thinking that it being included was overriding out code but using css will work as long as we can get the role set with our code.

    Thank you so much for your help! Looking forward to your reply 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 22201
    Brajesh Singh on #18971

    Hi Jeff,
    How are you creating the new roles.

    It seems to me it is not that the selected role is overriding, It is most probable that the member type equivalent role is not available when setting role.

    Please let me know who are you adding the role and I will find a way to do it.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 23
    y2gabs on #18989

    Hi Brajesh, thank you for your reply. I am creating a new user via the add new link in the admin via the standard user-new.php page. the role that should be set via our code is a custom role that is created using the “members” plugin (which allows you to create custom roles). I’d created 3 custom roles, associated them to 3 member types, and have named the roles with the exact same name as the member types. So the variable being passed to the selected member type is also being used to set the new user’s role. Does that make sense? Please let me know if you have any other questions.

    Thank you!

  • Participant
    Level: Enlightened
    Posts: 23
    y2gabs on #18990

    I’ve even created a custom user-new.php page and removed the role dropdown entirely from the form. Every time I create a new user, the role is not set to the corresponding member type name that is selected in the form. It always sets the role to the default role (subscriber).

  • Keymaster
    (BuddyDev Team)
    Posts: 22201
    Brajesh Singh on #19019

    Hi Jeff,
    My apologies for taking time before replying here.

    Is there a chance that you are using our Member Types pro plugin and you have Member Type to role or role to member type mapping configured?

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 23
    y2gabs on #19082

    Hi there, no worries. Yep, that’s exactly what my configuration and I’ve ensured that the name of each member type matches the name of the role associated to each member type (so that we can reuse the $MemberType variable)

    Thanks!

You must be logged in to reply to this topic.

This topic is: not resolved