• Resolved IT Hertz

    (@it-hertz)


    I just want to make sure I’m not missing something before submitting a feature request to your github.

    The statuses seem to be hard coded: class-user.php#L992

    Assuming there’s no way of doing this that I’ve overlooked, a hook here is needed for adding new statuses for custom actions.

    For example:
    I don’t want to allow subadmins to delete users, but I do want them to be able to mark users for deletion, which I will perform later if I agree with them.
    I have the status and role change working with:

    add_action( "um_admin_custom_hook_um_mark_for_deletion", function( $user_id ) {
        update_user_meta($user_id, 'account_status', 'inactive');
        UM()->roles()->set_role( $user_id, 'um_for-deletion' );
    });

    But, I either have to use an existing status and description, such as inactive (Membership Inactive), or add a new line to class-user.php to have my subadmins see “For Deletion” or similar, and of course I have to add this after plugin updates.

    Perhaps this was just an oversight? Hooks are provided for adding custom actions, but we can’t add statuses and descriptions to match?

    This can cause confusion, not to mention poor aesthetics, in the case of a custom action in the bulk dropdown that has little or nothing to do with any of the stock statuses.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @it-hertz

    Sorry for the late response. Did you manage to resolve your issue? Have you tried clearing the user cache after updating the role?

    You can use the following code snippet to clear the cache of a specific user:
    UM()->user()->remove_cache( $user_id );

    Thread Starter IT Hertz

    (@it-hertz)

    It’s not related to caching.

    I’ll try to explain a different way.
    I want to be able to set custom status text that corresponds to custom actions I have created via hook.

    Why would anyone want to do this?
    For example, let’s say I want to create a new action and status called “Premium”. None of the built-in statuses (Approved, Awaiting E-mail Confirmation, Pending Review, Membership Rejected, Membership Inactive) relate to being granted Premium status, yet one of the built-ins must nevertheless be displayed in the status column of the user table.

    Another example: I have created several custom actions for different reasons for rejecting membership, but there is only the “Membership Rejected” status that can be displayed to the subadmin who views the user list. It doesn’t tell them WHY the user was rejected.
    Suppose one subadmin rejects a user’s registration. Another subadmin logs in and sees the user was rejected but has no idea why until they bother contacting the other subadmins. This can cause inconvenience, delays, confusion and annoyance.
    I have also created a custom placeholder for the “rejected” UM email template so that it sends an email stating the reason for rejection. That user is better informed than my own subadmins in this regard. Not exactly ideal.

    I realize I could do this via roles instead of status, BUT… UM bases a lot of functions on role, such as access restrictions to pages and nav menu items, yet it bases emails, for example, on status.
    I’ve created functions that change user role based on status change and hides the roles column in the user table. Sure, I could reverse the process, changing status based on role change and hiding the status column instead of the role column, but I’d have to rewrite all the code I’ve already got working and I’d have to tweak the email handler as well.

    I don’t want to display both role and status columns, as that could cause confusion for subadmins, because, although a role can be named anything, the same cannot be said for statuses, and as I’ve suggested, the available status strings may not relate to their associated roles.
    Imagine the potential for confusion (e.g., “err. What role did that status belong with?? Who changed that role and what does that status mean now? What did that status mean again anyway??).

    Thread Starter IT Hertz

    (@it-hertz)

    I needed a number of new statuses, so I decided to do it via roles instead of using the limited number of stock statuses. I added custom email templates to deal with the various roles and scenarios.

    The hooks and email placeholders have been really helpful.
    Having a hook that allows for adding custom status labels would be a welcome enhancement.

    So, consider that a feature request, and I’ll mark this resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘hooks: custom status to match custom action?’ is closed to new replies.