upgrade_admin_caps(); } } add_action( 'user_register', array( $this, 'upgrade_new_admin_to_manager' ) ); } /** * Upgrade all existing administrators to have Translation Manager capabilities. * Also syncs with ATE via action */ public function upgrade_admin_caps() { $admins = get_users( array( 'role' => 'administrator' ) ); foreach ( $admins as $user ) { $user->add_cap( WPML_Manage_Translations_Role::CAPABILITY ); } do_action( 'wpml_tm_ate_synchronize_managers' ); update_option( self::HAS_RUN_OPTION, true ); } /** * Upgrade new administrator user to have Translation Manager capabilities. * Also syncs with ATE via action * * @param int $user_id */ public function upgrade_new_admin_to_manager( $user_id ) { $user = get_user_by( 'id', $user_id ); if ( in_array( 'administrator', $user->roles ) ) { $user->add_cap( WPML_Manage_Translations_Role::CAPABILITY ); do_action( 'wpml_tm_ate_synchronize_managers' ); } } }