• Resolved palopoliart7

    (@palopoliart7)


    Hello,

    I want to unset menu items in the GEAR ICON of the profile and in the members directory list when the logged-in user is an Admin.

    I want to unset those items :
    – Deactivate this account
    – Login as this user

    I could use this hook but I don’t know which name I should give to the menu item to unset it :

    function remove_menu_cancel_button( $items = array() ) { 
     if ( isset( $items['deactivate'] ) ) { 
     unset( $items['deactivate'] ); 
     } 
    return $items; 
    } 
    
    add_filter( 'um_myprofile_edit_menu_items', 'remove_menu_cancel_button', 12, 1 );

    Can you tell me what name to enter in this function to really unset those items ?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • @palopoliart7

    Try to use the um_admin_user_actions_hook filter.
    You have the source code here at lines 12/57

    .../plugins/ultimate-member/includes/core/um-filters-user.php

    Thread Starter palopoliart7

    (@palopoliart7)

    Thank you it worked perfectly!

    Thread Starter palopoliart7

    (@palopoliart7)

    If anyone is interested about the Filter function :

    /******* UNSET USER PROFILE MENU ITEMS *******/
    function unset_profile_menu_items($action, $user_id){
        um_fetch_user( $user_id );
    
    	$role = get_role( UM()->roles()->get_priority_user_role( get_current_user_id() ) );
    	$can_edit_users = current_user_can( 'edit_users' ) && $role->has_cap( 'edit_users' );
    
    	if ( $can_edit_users ){
    	    if ( um_user( 'account_status' ) == 'awaiting_admin_review' ) {
    			$actions['um_approve_membership'] = array( 'label' => __( 'Approve Membership', 'ultimate-member' ) );
    			$actions['um_reject_membership'] = array( 'label' => __( 'Reject Membership', 'ultimate-member' ) );
    		}
    
    		if ( um_user( 'account_status' ) == 'rejected' ) {
    			$actions['um_approve_membership'] = array( 'label' => __( 'Approve Membership', 'ultimate-member' ) );
    		}
    
    		if ( um_user( 'account_status' ) == 'approved' ) {
    			$actions['um_put_as_pending'] = array( 'label' => __( 'Put as Pending Review', 'ultimate-member' ) );
    		}
    
    		if ( um_user( 'account_status' ) == 'awaiting_email_confirmation' ) {
    			$actions['um_resend_activation'] = array( 'label' => __( 'Resend Activation E-mail', 'ultimate-member' ) );
    		}
    	}
    	
    	return $actions;
    }
    add_filter( 'um_admin_user_actions_hook', 'unset_profile_menu_items', 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Unset “Login as this User” and “Deactivate this account” menu items’ is closed to new replies.