• Resolved pantoeflou

    (@pantoeflou)


    Hi,

    I am using the upload file section in my member forms, however the file does not get saved with the profile when I use custom roles.

    I have created a new user role called “candidate” by cloning the default “subscriber” role – I used the user role editor plugin to clone the role

    Now when I create a user with the default WP role “subscriber” the file uploads works perfectly. However, when I change the user role to “candidate” then file uploads no longer works.

    When I assign both “candidate” and “subscriber” roles to the user then uploads also works.

    What am I missing to ensure that the newly created “candidate” role can upload documents the same as the “subscriber” role. I don’t really want to apply multiple roles to a user

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter pantoeflou

    (@pantoeflou)

    I found the issue on this one – If you have a better suggestion, please let me know

    In my functions.php it seems I am interrupting the “saving” process by forcing a redirect

    Below is a small snippet of what I was doing

    add_action("um_after_user_updated","um_custom_after_user_updated", 10, 3 );
    function um_custom_after_user_updated(  $user_id, $args, $to_update ){
    	if( empty( $user_id ) ) {
    		$user_id = get_current_user_id();
    	}
    	
    	$rolename = UM()->roles()->get_priority_user_role( $user_id );
    	$userdata = get_userdata( $user_id );
    
    	switch( $rolename ) {
    		case 'partner_pending':
    			// do other stuff on DB
    			// do other stuff on DB
    			header("Location: https://<mySite>/<userRole>/");
    			exit();
    			break;
    		default:
    			break;
    	}	
    }

    When I comment out the “exit();” everything works just fine

    I also have a hook into um_after_member_role_upgrade and when I remove “exit();” it seems that both of these custom functions runs, which leads me to believe that I only need to hook into um_after_member_role_upgrade OR um_after_user_updated to have some custom actions after profile saved is clicked … is that right?

    — Some context —

    Currently I have a user registering as “Role A” which requires email validation.

    From there I use the profile completeness plugin to auto update the user to “Role B” once a profile is complete. I then use the um_after_member_role_upgrade hook to set the profile back to “awaiting_admin_review” (this also logs the user out until review is passed). The goal here is to have admins review the profile before the user becomes “fully active” on the site as “Role B”

    Is there maybe a better way to achieve this with UM, or a better way to do the redirect after profile change without interrupting the saving process?

    • This reply was modified 3 years, 8 months ago by pantoeflou. Reason: more detail on process
    • This reply was modified 3 years, 8 months ago by pantoeflou.
    • This reply was modified 3 years, 8 months ago by pantoeflou.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @pantoeflou

    It’s a bit complicated.
    Is there maybe a better way to achieve this with UM, or a better way to do the redirect after profile change without interrupting the saving process?

    Are you trying to save with the Profile completeness form or the main Profile Form? If you’re customizing with UM Profile Completeness, please contact us via our website as we cannot provide support for premium extensions in the free support forum: https://ultimatemember.com/support/ticket/

    Regards,

    • This reply was modified 3 years, 8 months ago by Champ Camba.
    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 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Upload files with custom role’ is closed to new replies.