• Resolved fernandotakagi1

    (@fernandotakagi1)


    Hi, I’m having a bit trouble to set a role to a user by a button-click.

    I created a pop up that appears in the store page with two buttons:
    Button-1: on click close the pop up;
    Button-2: on click user set his own role.

    So, I acctualy have two dead end:
    1 – It’s possible to set a role to a guest-user?
    2 – I’m not sure if I’m making it right:

    I’ve created a HTML button with an ID;

    <button id="b2" onclick="profissional()">Sou profissional de beleza
    </button>

    Then add The function onclick;

    <script>
    	function profissional() { location.href = '/wp-includes/teste-teste.php';
    	}
    </script>

    And, inside the PHP file, the follow code:
    `<?php
    um_fetch_user( 25 );
    $ultimatemember->user->set_role(‘um_profissional-de-beleza’);
    ?>

    Regards,
    Fernando

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @fernandotakagi1

    The PHP should be:

    <?php
    $user_id = 25;
    $role = ‘um_profissional-de-beleza’;
    UM()->roles()->set_role( $user_id, $role );
    ?>

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I set a role to a user by a button click?’ is closed to new replies.